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

How can we use "validate" in scripts? #20

Open
rpgoldman opened this issue Sep 12, 2017 · 5 comments
Open

How can we use "validate" in scripts? #20

rpgoldman opened this issue Sep 12, 2017 · 5 comments

Comments

@rpgoldman
Copy link

I was planning to invoke validate in a script, and check to see if my plan validated using the customary check against exit status. But I was disappointed to find that even when validate emitted `Bad plan description!" its exit code was still zero.

Digging further, since the plan argument is optional, and it's possible to check multiple plans in a single run of validate, I can see why the exit code wasn't set. And, indeed, AFAICT if validate fails to parse a plan file, it gets a zero back from getPlan, which means it's just like the plan not being there.

But if validate doesn't set an exit code, how can one use it in a script?

@DerekLong101
Copy link
Contributor

DerekLong101 commented Sep 13, 2017 via email

@rpgoldman
Copy link
Author

Yes, I think that would be quite helpful. The alternative would be forcing scripts to parse output strings, which isn't very appealing.

@maltehelmert
Copy link

For our work, we have to parse the output anyway because we are also interested in what VAL says about the quality of the validated plans. I don't know if it's helpful for you, but we use the "downward-lab" package by Jendrik Seipp for this, which is available online. I don't know how difficult it would be to adapt Jendrik's code for other planning systems than Fast Downward.

@rpgoldman
Copy link
Author

See #66 where I started to implement @DerekLong101 's suggestion.

But it's not at all clear that's right. In fact, it looks like Validate succeeding (exit status == 0) might simply be a typo bug.

The original main() deletes the_plan and then sets it to 0, presumably to avoid use after free.

But then it unconditionally returns the_plan, which means on failure it returns 0.

Everywhere else in main seems to call exit(-1) when something goes wrong. So I'm starting to wonder if it wasn't just a mistake that failure to validate the plan sets exit status to zero.

If it was just a mistake, then main should just set the exit status to a non-zero value here, and we don't need a -x special flag or any special handling.

It's possible we should modify the code so that an error condition (failure to find a file named on the command line, e.g.) has a value distinct from successful processing but input not validated.

@rpgoldman
Copy link
Author

P.S. Since IANACPPP (I Am Not A C Plus Plus Programmer), what are those -1s for in the exit statements? Why not just use something like exit(1)? Was this deliberate?

and re

It's possible we should modify the code so that an error condition (failure to find a file named on the command line, e.g.) has a value distinct from successful processing but input not validated.

Maybe error conditions should be exit code 2 and failures to validate without error should be 1, or some such convention?

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

3 participants