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

Remove integration test dependencies on system binaries #425

Open
casey opened this issue May 3, 2019 · 2 comments
Open

Remove integration test dependencies on system binaries #425

casey opened this issue May 3, 2019 · 2 comments
Labels

Comments

@casey
Copy link
Owner

casey commented May 3, 2019

Various tests call external binaries including echo, cat, and sh. I'd like to extend Just to work on windows without requiring an installation of cygwin or git-bash, so these dependencies should be removed. Also, the Just package for Nix requires an awkward workaround to patch the correct location of these binaries: https://github.com/NixOS/nixpkgs/pull/59306/files

Fortunately, the functionality that Just requires from external commands is minimal:

  • echo to print the arguments to a command
  • cat to print out the effective contents of a shebang recipe
  • sh to call sleep to introduce a delay
  • sh to return a specific error code from a child process

In order to remove dependencies on these commands, I propose we add just-test binary, and make it available to integration tests by inserting its location into the PATH environment variable. just-test could be extended with subcommands as needed to support the functionality that tests require:

  • just-test cat FILE copies the contents of FILE to stdout
  • just-test sleep N sleeps for N seconds
  • just-test code I terminates with error code I
  • just-test echo A... echos arguments to standard output
@runeimp
Copy link

runeimp commented May 3, 2019

In Windows CMD you have all you need already. Mostly without change.

POSIX Windows CMD
cat FILE TYPE FILE
sleep N SLEEP N
echo "ARGS" ECHO "ARGS"
exit I EXIT I
$? %ErrorLevel%

The Windows commands are uppercase just for historical reasons. Case doesn't actually matter on Windows.

https://ss64.com/nt/type.html
https://ss64.com/nt/sleep.html
https://ss64.com/nt/echo.html
https://ss64.com/nt/exit.html
https://ss64.com/nt/errorlevel.html

The big question for me is the last part. As I'm not exactly sure your refering to $? regarding using sh to get the exit code. If you accessing the exit code directly via sh somehow then I'm fairly sure you can do the same with cmd.exe but I'm not certain. Or maybe you just need EXIT I?

PowerShell has it's options as well.

@casey
Copy link
Owner Author

casey commented May 3, 2019

Thanks for the links and the translation to CMD! I didn't know about ss64, it looks super useful.

I'm actually just using sh to return an exit code to the calling process, to make sure Just returns the correct return code when a process fails. For example, the justfile might be:

foo:
  exit 200

And all the test does is check that Just itself returns 200 when running the recipe.

@casey casey added this to the 1.0 milestone May 27, 2019
@casey casey modified the milestones: 1.0, eventually Nov 7, 2019
@casey casey removed this from the eventually milestone Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants