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

Run multiple cases in a toml file #25

Open
epage opened this issue Nov 10, 2021 · 2 comments
Open

Run multiple cases in a toml file #25

epage opened this issue Nov 10, 2021 · 2 comments
Labels
A-trycmd Area: trycmd package question Uncertainty is involved

Comments

@epage
Copy link
Contributor

epage commented Nov 10, 2021

*.trycmd files support this but not *.toml. This discrepancy can push someone to *.trycmd files when they might be best served by the extra control of *.toml files.

Open Issues

  • How do we handle expected stdout / stderr?
    • We currently read these from the file system which makes them global to the *.toml file.
    • If we add support for inline stdout, stderr, keep in mind
@pwinckles
Copy link

Couldn't you model it something like this, combing a few of the test cases in this project as an example:

bin.name = "bin-fixture"

[basic]

[sandbox]
fs.sandbox = true

[sandbox.env.add]
write = "file.txt = Goodbye\nWorld"
cat = "file.txt"

[stderr-to-stdout]
stderr-to-stdout = true

[stderr-to-stdout.env.add]
stdout = """
Hello
World!
"""
stderr = """
Goodnight
Moon!
"""

I haven't tried deserializing that, but I would expect that it'd look something like:

struct TomlFile {
    global: OneShot,
    cases: HashMap<String, OneShot>,
}

It might be a better idea to put the test cases in an array of tables though, [[cases]].

So, if there are no cases are defined the current behavior is used. If cases are defined, then the OneShot objects are resolved by defaulting their values to whatever is in the global context, applying any values set in the case, and using the case's name as the name of the case (that is to say, if the case basic is in the file tests.toml, then it will look for basic.in, basic.out, etc).

@epage
Copy link
Contributor Author

epage commented Feb 21, 2022

Since this issue was created, we've added inline stdout/stderr support (just too many disparate files to juggle in large cases like cargo-edit).

Now its just a matter of moving forward with implementing this. We'd need to use an Array of Tables for the cases since they are order-dependent. We'd also want the fs table to be global since the assumption is the fs is shared between runs.

So the data model would be to just expose the TryCmd struct. I think the only remaining question is if we should actually do:

pub enum TrycmdSpec {
    OneShot(OneShot),
    MultiStep(TryCmd),
}

I'm assuming so.

So after that, its just getting around to implementing this.

@epage epage added the A-trycmd label Apr 28, 2022
@settings settings bot removed the A-trycmd label Aug 14, 2023
@epage epage added the A-trycmd Area: trycmd package label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trycmd Area: trycmd package question Uncertainty is involved
Projects
None yet
Development

No branches or pull requests

2 participants