/
cache_key_04.exp
executable file
·50 lines (39 loc) · 1.51 KB
/
cache_key_04.exp
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
#!/usr/bin/env -S expect -f
# For testing environment variables written to GITHUB_ENV
set gitHubEnvFile cache_key_04.txt
set ::env(GITHUB_ENV) $gitHubEnvFile
# For testing outputs variables written to GITHUB_OUTPUT
set gitHubOutputFile cache_key_output_04.txt
set ::env(GITHUB_OUTPUT) $gitHubOutputFile
set timeout 3
spawn ../../bin/cache_key.sh "Linux" "8.1.1" "lowest" "--ignore-platform-reqs --optimize-autoloader" "long-files-hash"
match_max 100000
expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer---ignore-platform-reqs---optimize-autoloader-lowest-long-files-hash'"
expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer---ignore-platform-reqs---optimize-autoloader-lowest-'"
expect eof
# Confirm environment variables.
set fp [open $gitHubEnvFile r]
set fileData [read $fp]
close $fp
set expectedValue "CACHE_RESTORE_KEY<<EOF
Linux-php-8.1.1-composer---ignore-platform-reqs---optimize-autoloader-lowest-
EOF
"
if { $expectedValue != $fileData } {
puts "\nExpected environment variable does not match. Received:\n"
puts $fileData
exit 1
}
# Verify output variables have been set correctly.
set fp [open $gitHubOutputFile r]
set fileData [read $fp]
close $fp
set expectedValue "key=Linux-php-8.1.1-composer---ignore-platform-reqs---optimize-autoloader-lowest-long-files-hash\n"
if { $expectedValue != $fileData } {
puts "\nExpected output variable does not match. Received:\n"
puts $fileData
exit 1
}
# Clean up
file delete $gitHubEnvFile
file delete $gitHubOutputFile