mirror of
https://github.com/imjasonh/testscript-rs
synced 2026-07-10 18:11:42 +00:00
Implement network and advanced condition support
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
This commit is contained in:
parent
8f82c9c11b
commit
26a39e2384
8 changed files with 335 additions and 3 deletions
19
testdata/env_conditions.txt
vendored
Normal file
19
testdata/env_conditions.txt
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Test environment variable conditions
|
||||
|
||||
# Set an env var in the test
|
||||
env TEST_VAR=hello
|
||||
|
||||
# This should execute since TEST_VAR is now set
|
||||
[env:TEST_VAR] exec echo "Environment variable TEST_VAR is set"
|
||||
[env:TEST_VAR] stdout "Environment variable TEST_VAR is set"
|
||||
|
||||
# This should be skipped since MISSING_VAR is not set
|
||||
[env:MISSING_VAR] exec echo "This should not appear"
|
||||
|
||||
# This should execute since MISSING_VAR is not set (negated condition)
|
||||
[!env:MISSING_VAR] exec echo "MISSING_VAR is not set (as expected)"
|
||||
[!env:MISSING_VAR] stdout "MISSING_VAR is not set (as expected)"
|
||||
|
||||
# Test PATH environment variable which should exist on all systems
|
||||
[env:PATH] exec echo "PATH environment variable exists"
|
||||
[env:PATH] stdout "PATH environment variable exists"
|
||||
11
testdata/network_conditions.txt
vendored
Normal file
11
testdata/network_conditions.txt
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Test network condition support
|
||||
|
||||
# This command will only run if network is available
|
||||
[net] exec echo "Network is available"
|
||||
|
||||
# This command will only run if network is not available
|
||||
[!net] exec echo "Network is not available"
|
||||
|
||||
# At least one of the above should execute, so we should see some output
|
||||
exec echo "Network test completed"
|
||||
stdout "Network test completed"
|
||||
16
testdata/program_conditions.txt
vendored
Normal file
16
testdata/program_conditions.txt
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Test program detection conditions
|
||||
|
||||
# Test that echo is available (should work on all platforms)
|
||||
[exec:echo] exec echo "echo command is available"
|
||||
[exec:echo] stdout "echo command is available"
|
||||
|
||||
# Test negation for a program that shouldn't exist
|
||||
[!exec:nonexistent_program_xyz123] exec echo "nonexistent program not found"
|
||||
[!exec:nonexistent_program_xyz123] stdout "nonexistent program not found"
|
||||
|
||||
# Test built-in program detections that are set by default
|
||||
[exec:ls] exec echo "ls command detected"
|
||||
[exec:mkdir] exec echo "mkdir command detected"
|
||||
|
||||
# At least mkdir should work since it's tested
|
||||
[exec:mkdir] stdout "mkdir command detected"
|
||||
Loading…
Add table
Add a link
Reference in a new issue