Skip to content

lib/path/tests: Fix property tests when "-n" is generated#210042

Merged
infinisil merged 1 commit intoNixOS:masterfrom
tweag:lib.path-tests-fix
Jan 10, 2023
Merged

lib/path/tests: Fix property tests when "-n" is generated#210042
infinisil merged 1 commit intoNixOS:masterfrom
tweag:lib.path-tests-fix

Conversation

@infinisil
Copy link
Member

@infinisil infinisil commented Jan 10, 2023

Description of changes

When "-n" is generated by the property tests, it causes echo to not output the string since it's interpreted as an option. Apparently there's no good way to print "-n" with echo, so switching to printf instead

Thanks to @vcunat for reporting the original failure in the PR that introduced it

I love this, while the property tests didn't detect a mistake in the code implementation, they did detect a mistake in the test implementation!

This work is sponsored by Antithesis

Things done
  • Successfully ran lib/path/tests/prop.sh 13110

When "-n" is generated by the property tests, it causes `echo` to not
output the string since it's interpreted as an option. Apparently
there's no good way to print "-n" with `echo` [1], so switching to
`printf` instead

[1]: https://unix.stackexchange.com/questions/85846/how-can-i-print-n-with-echo
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 10, 2023
@infinisil infinisil merged commit 80a68f8 into NixOS:master Jan 10, 2023
@infinisil infinisil deleted the lib.path-tests-fix branch January 10, 2023 14:52
@fricklerhandwerk
Copy link
Contributor

You should use -- to mark the end of options to printf, otherwise dashes will be interpreted as options, which amounts to roughly the same problem as before.

@vcunat
Copy link
Member

vcunat commented Jan 10, 2023

I don't think so, from docs or test

$ printf %s --help
--help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants