Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Fix #19.
Browse files Browse the repository at this point in the history
This commit also extends the testing framework to support comparing
stdout with expected stdout. I think the time has probably come to
rewrite the test harness in Rust, but it was a fun exercise to write
some non-trivial Bash! :)

Fix ended up being super simple, I think this code was left over from
before script running was a separate command.
  • Loading branch information
LPGhatguy committed Jul 6, 2020
1 parent 9e3f8fd commit 5d59d97
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Remodel Changelog

## Unreleased Changes
* Fixed first argument to `remodel run` script being eaten by Remodel. ([#19](https://github.com/Roblox/remodel/issues/19))

## 0.7.0 (2020-04-19)
* **Breaking**: Moved script execution to `remodel run` to make room for new subcommands.
Expand Down
22 changes: 20 additions & 2 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,26 @@ fi
mkdir temp

for script in test-scripts/*.lua; do
echo "Running $(basename "$script" .lua)"
./target/debug/remodel run "$script"
test_name=$(basename "$script" .lua)
output_file="test-scripts/$test_name.expected"

echo "Running $test_name"
output=$(./target/debug/remodel run "$script" arg1 arg2 arg3)

if [ -f $output_file ]; then
expected_output=$(cat "$output_file")

if [ "$output" = "$expected_output" ]; then
echo "Output was correct."
else
echo "Test failed!"
echo "Expected output:"
echo "$expected_output"
echo "Actual output:"
echo "$output"
exit 2
fi
fi
done

if [ ! -z "${REMODEL_AUTH_TESTS}" ]; then
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ fn run(options: Options) -> Result<(), anyhow::Error> {
lua.context(move |context| {
let lua_args = args
.into_iter()
.skip(1)
.map(|value| value.to_lua(context))
.collect::<Result<Vec<_>, _>>()?;

Expand Down
3 changes: 3 additions & 0 deletions test-scripts/args.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Arg 1 arg1
Arg 2 arg2
Arg 3 arg3
3 changes: 3 additions & 0 deletions test-scripts/args.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for i = 1, select("#", ...) do
print("Arg", i, (select(i, ...)))
end
2 changes: 0 additions & 2 deletions test-scripts/read-dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ local testScripts = remodel.readDir("test-scripts")
local fileCount = 0
local foundSelf = false
for _, file in ipairs(testScripts) do
assert(file:find("%.lua$") ~= nil)

if file == "read-dir.lua" then
foundSelf = true
end
Expand Down

0 comments on commit 5d59d97

Please sign in to comment.