-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add diffing support to bash tests #531
Comments
My name was mentioned? Drop the trailing semicolons. Use snake case naming consistently, including function names. Prefer printf over echo. Replace your |
If you're going to show diffs, you may want to actually show the diff, not just the want/expect. |
Sorry about the mention, you always give great feedback |
@MichaelDimmitt Feel free to mention me any time you want someone pedantic to nitpick your shell code :) |
Went with cmp for readibility purposesalso started a discussion on bats-core 🎉 bats-core/bats-core#490 printDiff(){
echo ;
echo output;
echo "$output";
echo ;
echo expected;
echo "$expected";
echo ;
cmp <(echo "$output") <(echo "$expected") | cut -c 23-;
echo ;
}
@test "a failure on line 1" {
run bash two_fer.sh Alice
expected=$(cat <<-END
test should fail
this is some text
END
)
output=$(cat <<-END
test should pass
this is some text
END
)
printDiff
[[ "$output" == "$expected" ]]
}
@test "a failure on line 2" {
run bash two_fer.sh Alice
expected=$(cat <<-END
this is some text
test should fail
END
)
output=$(cat <<-END
this is some text
test should pass
END
)
printDiff
[[ "$output" == "$expected" ]]
}
@test "a bad diff occurs if expected is 2 lines but output is 1 line" {
run bash two_fer.sh Alice
expected=$(cat <<-END
this is some text
test should fail
END
)
output=$(cat <<-END
this is some text
END
)
printDiff
[[ "$output" == "$expected" ]]
} |
On a successful test, will this echo the output two times? |
I'm coming around to this. With the v3 release of exercism, showing students that |
Diffing is easy to attain in bats
If you add printDiff to every function.
It will only show the output if the test fails.
curious if @IsaacG has thoughts.
by changing
This actually just saved me on a project.
And I am sourcing the scripts like libs as is proposed in the pending pr
#373
The text was updated successfully, but these errors were encountered: