forked from ramsey/composer-install
/
cache_key_07.exp
executable file
·50 lines (39 loc) · 1.3 KB
/
cache_key_07.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_07.txt
set ::env(GITHUB_ENV) $gitHubEnvFile
# For testing outputs variables written to GITHUB_OUTPUT
set gitHubOutputFile cache_key_output_07.txt
set ::env(GITHUB_OUTPUT) $gitHubOutputFile
set timeout 3
spawn ../../bin/cache_key.sh "Windows" "8.0.2" "foobar" "" "some-other-hash"
match_max 100000
expect -exact "::debug::Cache primary key is 'Windows-php-8.0.2-composer-locked-some-other-hash'"
expect -exact "::debug::Cache restore keys are 'Windows-php-8.0.2-composer-locked-'"
expect eof
# Confirm environment variables.
set fp [open $gitHubEnvFile r]
set fileData [read $fp]
close $fp
set expectedValue "CACHE_RESTORE_KEY<<EOF
Windows-php-8.0.2-composer-locked-
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=Windows-php-8.0.2-composer-locked-some-other-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