Skip to content

Conversation

christarazi
Copy link
Member

This is useful if there are commands that output values that could be
used as parameters to subsequent commands.

Also modify the scripttest runner when verbose mode is set to execute
the "env" command using ExecuteLine() instead of running Env() directly
because we now need the flags to be initialized.

Signed-off-by: Chris Tarazi chris@isovalent.com

@christarazi christarazi requested a review from a team as a code owner October 1, 2025 20:02
@christarazi christarazi requested review from pippolo84 and removed request for a team October 1, 2025 20:02
@christarazi
Copy link
Member Author

cc @joamaki

Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM ✅

I'd suggest to add a test for env like the following:

# set an env var
env TEST=value
env TEST
cmp stdout stdout_env.txt

# set an env var from stdout
echo hello
env --from-stdout TEST
env TEST
cmp stdout stdout_env_stdout.txt

# set multiple env vars from stdout
echo world
env --from-stdout TEST1 TEST2
env TEST1
cmp stdout stdout_env_stdout_1.txt
env TEST2
cmp stdout stdout_env_stdout_2.txt

-- stdout_env.txt --
TEST=value
-- stdout_env_stdout.txt --
TEST=hello
-- stdout_env_stdout_1.txt --
TEST1=world
-- stdout_env_stdout_2.txt --
TEST2=world

@christarazi christarazi force-pushed the pr/christarazi/env-stdout branch from f0b969c to d666767 Compare October 6, 2025 21:03
@christarazi
Copy link
Member Author

@pippolo84 I agree with adding tests but I don't see any other command being tested in a txtar-style test (unless I've missed it somehow). Is this something we still want to do? I'm not sure if this was a specific reason to not have these kinds of tests in this repo.

@christarazi christarazi requested a review from pippolo84 October 6, 2025 21:22
@pippolo84
Copy link
Member

@pippolo84 I agree with adding tests but I don't see any other command being tested in a txtar-style test (unless I've missed it somehow). Is this something we still want to do? I'm not sure if this was a specific reason to not have these kinds of tests in this repo.

I see a .txtar based test for Empty and Sed, for example. I'm not aware of any limitation regarding script based tests for commands, but let's hear from @joamaki too.

This is useful if there are commands that output values that could be
used as parameters to subsequent commands.

Also modify the scripttest runner when verbose mode is set to execute
the "env" command using ExecuteLine() instead of running Env() directly
because we now need the flags to be initialized.

Co-authored-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
Signed-off-by: Chris Tarazi <chris@isovalent.com>
@christarazi christarazi force-pushed the pr/christarazi/env-stdout branch from d666767 to 8b0697d Compare October 7, 2025 18:55
@christarazi
Copy link
Member Author

@pippolo84 Ah thanks for the pointer, I missed those files. I added what you suggested and credited you in the commit, thanks!

@joamaki joamaki merged commit 21f6f6e into main Oct 8, 2025
1 check passed
@joamaki joamaki deleted the pr/christarazi/env-stdout branch October 8, 2025 07:39
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

Successfully merging this pull request may close these issues.

3 participants