-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathenv.exp
More file actions
63 lines (51 loc) · 3.01 KB
/
env.exp
File metadata and controls
63 lines (51 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/expect
# uncomment line below for debugging
# exp_internal 1
set timeout 7
source ./ci/expect_scripts/shared-code.exp
spawn $env(TESTS_DIR)env
expect "Testing Env module functions..." {
expect -re "Testing Env.cwd!:" {
# Match cwd path that has ArbitraryBytes with non-empty list of integers
# Use curly braces for the regex pattern to avoid Tcl interpretation of [ and ]
expect -re {cwd: \(@InternalPath \(ArbitraryBytes \[\d+(, \d+)*\]\)\)} {
expect -re "Testing Env.exe_path!:" {
# Match exe_path with any valid format
expect -re {exe_path: \(@InternalPath \(.*\[\d+(, \d+)*\].*\)\)} {
expect -re "Testing Env.platform!:" {
# Match platform info with any arch and OS
# Literal braces in regex need to be escaped: \{ and \}
expect -re {Current platform:\{arch: \w+, os: \w+\}} {
expect -re "Testing Env.dict!:" {
# Match environment variables count as non-zero number
expect -re {Environment variables count: (\d+)} {
set env_count $expect_out(1,string)
if {$env_count == 0} {
puts stderr "\nExpect script failed: environment variable count is zero."
exit 1
}
# Match sample environment variables with non-empty strings
# Literal brackets [], parentheses (), and quotes "" need escaping or careful handling
expect -re {Sample environment variables:\[\("\w+", ".*"\)(, \("\w+", ".*"\))*\]} {
expect -re "Testing Env.set_cwd!:" {
# Match changed directory path with non-empty list of integers
expect -re {Changed current directory to: \(@InternalPath \(ArbitraryBytes \[\d+(, \d+)*\]\)\)} {
expect "All tests executed!" {
expect eof {
check_exit_and_segfault
}
}
}
}
}
}
}
}
}
}
}
}
}
}
puts stderr "\nExpect script failed: output was different from expected value."
exit 1