Skip to content
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

Improve output when string not equal for long strings #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

daveshepherd
Copy link

No description provided.

shunit2 Outdated Show resolved Hide resolved
shunit2 Outdated Show resolved Hide resolved
shunit2 Outdated
_shunit_assertFail "${shunit_message_:+${shunit_message_} }diff:<${diff_output_}>"
else
_shunit_assertFail "${shunit_message_:+${shunit_message_} }expected:<${shunit_expected_}> but was:<${shunit_actual_}>"
fi

unset shunit_message_ shunit_expected_ shunit_actual_
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add your new variable here.

shunit2 Outdated
@@ -630,7 +630,12 @@ failNotEquals() {
shunit_actual_=$2

shunit_message_=${shunit_message_%% }
_shunit_assertFail "${shunit_message_:+${shunit_message_} }expected:<${shunit_expected_}> but was:<${shunit_actual_}>"
if command [ $(echo "${shunit_expected_}" | wc -l) -gt 10 ] || command [ $(echo "${shunit_actual_}" | wc -l) -gt 10 ]; then
diff_output_=$(diff <(echo "${shunit_expected_}") <(echo "${shunit_actual_}"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize process substitution <() as a Bashism, though I don't know the details.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is process substitution, it provides a way of passing the output of a command to another command where pipe is not available. diff takes filenames, but the items that want to be diff'd are in variables.
I suspect this might be why the tests are failing, as it probably doesn't work in other shells.
If anyone has any suggestions on how I can do this differently then let me know.

shunit2 Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants