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

[EXE] not being removed #140

Closed
SUPERCILEX opened this issue Oct 1, 2022 · 9 comments
Closed

[EXE] not being removed #140

SUPERCILEX opened this issue Oct 1, 2022 · 9 comments

Comments

@SUPERCILEX
Copy link
Contributor

On windows, my tests are failing because [EXE] shows up: https://github.com/SUPERCILEX/ftzz/actions/runs/3161445260/jobs/5147037527. I thought it was supposed to be removed? In general, I don't understand variables. The docs are very unclear. Are they replacing input or output? Is the value a search string? Or is the var replaced with the value? Tried both and neither did anything. Examples are needed of what happens to the output or input when a variable is added.

@epage
Copy link
Contributor

epage commented Oct 3, 2022

Variables are applied to the actual output so we the stored snapshots are consistent.

Still catching up on your other things so I can see what the full conversation is about improving this

@SUPERCILEX
Copy link
Contributor Author

Hmmm, still don't get it unfortunately. Let say I have t.insert_var("[FOO]", "Hello").unwrap(); And then this test:

$ echo-hello "[FOO]"
Hello [FOO]!

Why isn't Hello replaced with [FOO] (I think this is what's supposed to happen) or [FOO] replaced with Hello (or this)?

@epage
Copy link
Contributor

epage commented Oct 4, 2022

A more complete reproduction case is needed to give you an answer.

@SUPERCILEX
Copy link
Contributor Author

Can you describe what it's supposed to do? I still don't know since I've never seen it work.

@epage
Copy link
Contributor

epage commented Oct 4, 2022

See the use of [EXE] in this subsection of clap's tutorial

On windows, we run the specified command. We then normalize the output which includes finding .exe and replacing it with [EXE]. We then compare this with the file on disk and error if they are different. If the user instead specifies overwrite, we will write out the normalized output to disk.

On Linux, we see that {EXE] maps to nothing. This works because when we normalize, we normalize to the file on disk as a template. We see that [EXE] is on disk and so we keep it in the output.

@SUPERCILEX
Copy link
Contributor Author

Ohhh, I get, thanks! So the example would be

$ echo-hello Blah
[FOO] Blah!

and t.insert_var("[FOO]", "Hello").unwrap(); allows the Hello to optionally be replaced with [FOO] in the on-disk output.

@epage
Copy link
Contributor

epage commented Oct 4, 2022

Yes!

I mainly use this for things that are dependent on the test environment (paths, file extensions, etc) but cargo-test-support, which this was partially based on, uses variables for a lot more. Most of that is to make it easier to update as the tests using that are not using snapshots yet.

@epage
Copy link
Contributor

epage commented Oct 4, 2022

clap-rs/clap#4348 serves as an example for [EXE]. Someone added new examples that failed on Windows because the literal usage is Usage: 04_01_enum_derive.exe <MODE> on Windows so they added EXE to the markdown and it should now pass.

@SUPERCILEX
Copy link
Contributor Author

Yup yup, I'm waiting on SUPERCILEX/ftzz@122bf54 to go green. Will reopen this issue if not.

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