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

Standardized scheme-eval command #15

Open
lassik opened this issue Nov 3, 2020 · 6 comments
Open

Standardized scheme-eval command #15

lassik opened this issue Nov 3, 2020 · 6 comments

Comments

@lassik
Copy link
Contributor

lassik commented Nov 3, 2020

For portability-testing a feature across many implementations, it would be great if we could do something like this:

docker run schemers/bigloo scheme-eval "(+ 1 (* 2 3))"

It would evaluate the expression.

  • On success, write the results to standard output as Scheme forms, one value per line, and exit with code 0.
  • On failure, write free-form info about the exception to stderr, and exit with nonzero code.

If this works consistently across containers (as scheme-script now does among many) it would be easy to write a runner script to launch containers for a test, collect and curate the results.

@lassik lassik changed the title Command to evaluate an expression and print the result Standardized scheme-eval command Nov 3, 2020
@lassik
Copy link
Contributor Author

lassik commented Nov 6, 2020

Now there is:

$ docker run schemers/gauche:head scheme-eval "(print (+ 1 2 3))"; echo "exit $?"
6
exit 0
$ docker run schemers/gauche:head scheme-eval "(print (+ 1 2 wrong))"; echo "exit $?"
gosh: "ERROR": unbound variable: wrong
exit 1

This demonstrates that exceptions go to stderr:

$ docker run schemers/gauche:head scheme-eval "(print (+ 1 2 wrong))" >/dev/null; echo "exit $?"
gosh: "ERROR": unbound variable: wrong
exit 1

Need to call print (or write) manually; otherwise nothing is printed.

@lassik
Copy link
Contributor Author

lassik commented Nov 6, 2020

How to handle R6RS vs R7RS eval for Schemes that have both? Should we permit passing custom command line arguments in addition to the thing-to-be-evaled?

@amirouche
Copy link
Member

What about using --mount as part of docker and eval a file instead of string?

@lassik
Copy link
Contributor Author

lassik commented Nov 6, 2020

That is definitely possible, but slightly more complex. We'd have to make a tempfile on the host OS, give the --mount flag, and write a somewhat more complex runner script. The current one is very simple.

However, you'd be right that evaling a big expression is not very convenient this way.

One option is to read code from stdin, which would let us pass an entire source file without a mount.

@lassik
Copy link
Contributor Author

lassik commented Nov 6, 2020

Ideally we'd have a DSL on the host side to write portability tests like this:

(define-test "Is `constantly` defined like in Common Lisp?"
  (for bigloo chibi gauche guile)
  (eval (begin (write ((constantly 123) 1 2 3)) (newline)))
  (expect-value 123))

Then a runner would run them. Perhaps the list of Schemes in (for ...) should be given by the user and not hard-coded.

@lassik
Copy link
Contributor Author

lassik commented Nov 6, 2020

For evaling a lot of code at one, yet another option is to pipe an uncompressed .tar archive to stdin, extract it in the container, and run it. This would let us ship as many files as we want without worrying setting up mounts.

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

No branches or pull requests

2 participants