From 9ed951e597fd9bf09ab150b732fc5faebf60af9a Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Thu, 13 Oct 2022 21:27:28 -0400 Subject: [PATCH 01/10] First pass at removing `set-output`. `set-output` has been deprecated. See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/. --- bin/cache_key.sh | 2 +- bin/composer_paths.sh | 8 +++--- bin/php_version.sh | 4 +-- bin/should_cache.sh | 2 +- tests/expect/cache_key_01.exp | 17 +++++++++++- tests/expect/cache_key_02.exp | 16 ++++++++++- tests/expect/cache_key_03.exp | 16 ++++++++++- tests/expect/cache_key_04.exp | 16 ++++++++++- tests/expect/cache_key_05.exp | 16 ++++++++++- tests/expect/cache_key_06.exp | 16 ++++++++++- tests/expect/cache_key_07.exp | 16 ++++++++++- tests/expect/composer.lock | 2 +- tests/expect/composer_paths_01.exp | 26 +++++++++++++++--- tests/expect/composer_paths_05.exp | 26 +++++++++++++++--- tests/expect/composer_paths_06.exp | 26 +++++++++++++++--- tests/expect/composer_paths_08.exp | 26 +++++++++++++++--- tests/expect/composer_paths_09.exp | 26 +++++++++++++++--- tests/expect/php_version_01.exp | 23 ++++++++++++++-- tests/expect/should_cache_01.exp | 19 ++++++++++++- tests/expect/should_cache_02.exp | 19 ++++++++++++- tests/expect/should_cache_03.exp | 19 ++++++++++++- tests/expect/should_cache_04.exp | 19 ++++++++++++- tests/expect/should_cache_05.exp | 19 ++++++++++++- tests/expect/should_cache_06.exp | 19 ++++++++++++- tests/expect/should_cache_07.exp | 19 ++++++++++++- tests/expect/should_cache_08.exp | 19 ++++++++++++- tests/fixtures/with-lock-file/composer.lock | 30 ++++++++++++++------- 27 files changed, 411 insertions(+), 55 deletions(-) diff --git a/bin/cache_key.sh b/bin/cache_key.sh index 966e852..f9da134 100755 --- a/bin/cache_key.sh +++ b/bin/cache_key.sh @@ -57,7 +57,7 @@ cache_key="$(make_key "${key[@]}")" echo "::debug::Cache primary key is '${cache_key}'" echo "::debug::Cache restore keys are '$(join_by ", " "${uniq_restore_key[@]}")'" -echo "::set-output name=key::${cache_key}" +echo "key=${cache_key}" >> "${GITHUB_OUTPUT}" # Use an environment variable to capture the multiline restore key. # See: https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#multiline-strings diff --git a/bin/composer_paths.sh b/bin/composer_paths.sh index 8c327ff..ec866be 100755 --- a/bin/composer_paths.sh +++ b/bin/composer_paths.sh @@ -53,7 +53,7 @@ echo "::debug::${composer_version}" echo "::debug::Composer cache directory found at '${cache_dir}'" echo "::debug::File composer.json found at '${composer_json}'" echo "::debug::File composer.lock path computed as '${composer_lock}'" -echo "::set-output name=command::${composer_path}" -echo "::set-output name=cache-dir::${cache_dir}" -echo "::set-output name=json::${composer_json}" -echo "::set-output name=lock::${composer_lock}" +echo "command=${composer_path}" >> "${GITHUB_OUTPUT}" +echo "cache-dir=${cache_dir}" >> "${GITHUB_OUTPUT}" +echo "json=${composer_json}" >> "${GITHUB_OUTPUT}" +echo "lock=${composer_lock}" >> "${GITHUB_OUTPUT}" diff --git a/bin/php_version.sh b/bin/php_version.sh index 746c05c..e637e03 100755 --- a/bin/php_version.sh +++ b/bin/php_version.sh @@ -16,5 +16,5 @@ php_version=$($php_path -r 'echo phpversion();') echo "::debug::PHP path is '${php_path}'" echo "::debug::PHP version is '${php_version}'" -echo "::set-output name=path::${php_path}" -echo "::set-output name=version::${php_version}" +echo "path=${php_path}" >> "${GITHUB_OUTPUT}" +echo "version=${php_version}" >> "${GITHUB_OUTPUT}" diff --git a/bin/should_cache.sh b/bin/should_cache.sh index 33c2c61..95cbcd0 100755 --- a/bin/should_cache.sh +++ b/bin/should_cache.sh @@ -15,4 +15,4 @@ if [ $should_cache -eq 0 ]; then fi echo "::debug::We ${will_cache} the dependencies because ignore-cache is set to '${ignore_cache}'" -echo "::set-output name=do-cache::${should_cache}" +echo "do-cache=${should_cache}" >> "${GITHUB_OUTPUT}" diff --git a/tests/expect/cache_key_01.exp b/tests/expect/cache_key_01.exp index 63e402b..3336041 100755 --- a/tests/expect/cache_key_01.exp +++ b/tests/expect/cache_key_01.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_01.txt set ::env(GITHUB_ENV) $gitHubEnvFile +set gitHubOutputFile cache_key_output_01.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 spawn ../../bin/cache_key.sh @@ -9,7 +11,7 @@ match_max 100000 expect -exact "::debug::Cache primary key is 'php-composer-locked'" expect -exact "::debug::Cache restore keys are 'php-composer-locked-'" -expect -exact "::set-output name=key::php-composer-locked" + expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +29,18 @@ if { $expectedValue != $fileData } { exit 1 } +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "key=php-composer-locked\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 diff --git a/tests/expect/cache_key_02.exp b/tests/expect/cache_key_02.exp index c7a5b20..fe3fee8 100755 --- a/tests/expect/cache_key_02.exp +++ b/tests/expect/cache_key_02.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_02.txt set ::env(GITHUB_ENV) $gitHubEnvFile +set gitHubOutputFile cache_key_output_02.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 spawn ../../bin/cache_key.sh "Linux" "8.1.1" "" "" "long-files-hash" @@ -9,7 +11,6 @@ match_max 100000 expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-long-files-hash'" expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-'" -expect -exact "::set-output name=key::Linux-php-8.1.1-composer-locked-long-files-hash" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "key=Linux-php-8.1.1-composer-locked-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 diff --git a/tests/expect/cache_key_03.exp b/tests/expect/cache_key_03.exp index 58bfaf6..6315e7d 100755 --- a/tests/expect/cache_key_03.exp +++ b/tests/expect/cache_key_03.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_03.txt set ::env(GITHUB_ENV) $gitHubEnvFile +set gitHubOutputFile cache_key_output_03.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 spawn ../../bin/cache_key.sh "Linux" "8.1.1" "locked" "" "long-files-hash" @@ -9,7 +11,6 @@ match_max 100000 expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-long-files-hash'" expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-'" -expect -exact "::set-output name=key::Linux-php-8.1.1-composer-locked-long-files-hash" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "key=Linux-php-8.1.1-composer-locked-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 diff --git a/tests/expect/cache_key_04.exp b/tests/expect/cache_key_04.exp index 9580171..b02dd09 100755 --- a/tests/expect/cache_key_04.exp +++ b/tests/expect/cache_key_04.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_04.txt set ::env(GITHUB_ENV) $gitHubEnvFile +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" @@ -9,7 +11,6 @@ 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 -exact "::set-output name=key::Linux-php-8.1.1-composer---ignore-platform-reqs---optimize-autoloader-lowest-long-files-hash" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +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 diff --git a/tests/expect/cache_key_05.exp b/tests/expect/cache_key_05.exp index 242c4ff..6e416bf 100755 --- a/tests/expect/cache_key_05.exp +++ b/tests/expect/cache_key_05.exp @@ -1,7 +1,9 @@ #!/usr/bin/env -S expect -f set gitHubEnvFile cache_key_05.txt +set gitHubOutputFile cache_key_output_05.txt set ::env(GITHUB_ENV) $gitHubEnvFile +set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 spawn ../../bin/cache_key.sh "Linux" "8.1.1" "locked" "" "long-files-hash" "my-custom-key" @@ -9,7 +11,6 @@ match_max 100000 expect -exact "::debug::Cache primary key is 'my-custom-key'" expect -exact "::debug::Cache restore keys are ''" -expect -exact "::set-output name=key::my-custom-key" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "key=my-custom-key\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 diff --git a/tests/expect/cache_key_06.exp b/tests/expect/cache_key_06.exp index 0706cfb..ecff5dd 100755 --- a/tests/expect/cache_key_06.exp +++ b/tests/expect/cache_key_06.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_06.txt set ::env(GITHUB_ENV) $gitHubEnvFile +set gitHubOutputFile cache_key_output_06.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 spawn ../../bin/cache_key.sh "Linux" "8.1.1" "" "" "long-files-hash" "" "path/to/working/dir" @@ -9,7 +11,6 @@ match_max 100000 expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-path/to/working/dir-long-files-hash'" expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-path/to/working/dir-'" -expect -exact "::set-output name=key::Linux-php-8.1.1-composer-locked-path/to/working/dir-long-files-hash" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "key=Linux-php-8.1.1-composer-locked-path/to/working/dir-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 diff --git a/tests/expect/cache_key_07.exp b/tests/expect/cache_key_07.exp index 7721b3b..dc39d3f 100755 --- a/tests/expect/cache_key_07.exp +++ b/tests/expect/cache_key_07.exp @@ -2,6 +2,8 @@ set gitHubEnvFile cache_key_07.txt set ::env(GITHUB_ENV) $gitHubEnvFile +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" @@ -9,7 +11,6 @@ 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 -exact "::set-output name=key::Windows-php-8.0.2-composer-locked-some-other-hash" expect eof set fp [open $gitHubEnvFile r] @@ -27,5 +28,18 @@ if { $expectedValue != $fileData } { exit 1 } +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 diff --git a/tests/expect/composer.lock b/tests/expect/composer.lock index f76f733..4207769 100644 --- a/tests/expect/composer.lock +++ b/tests/expect/composer.lock @@ -64,5 +64,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.0.0" } diff --git a/tests/expect/composer_paths_01.exp b/tests/expect/composer_paths_01.exp index 4d3f3a9..a23e8b7 100755 --- a/tests/expect/composer_paths_01.exp +++ b/tests/expect/composer_paths_01.exp @@ -1,5 +1,8 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile composer_paths_01.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/composer_paths.sh match_max 100000 @@ -9,9 +12,24 @@ expect "::debug::Composer path is '*'\r ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at './composer.json'\r ::debug::File composer.lock path computed as './composer.lock'\r -::set-output name=command::*\r -::set-output name=cache-dir::*\r -::set-output name=json::./composer.json\r -::set-output name=lock::./composer.lock\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "command=*\r +cache-dir=*\r +json=./composer.json\r +lock=./composer.lock\n +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/composer_paths_05.exp b/tests/expect/composer_paths_05.exp index 5e81a89..ae5bd69 100755 --- a/tests/expect/composer_paths_05.exp +++ b/tests/expect/composer_paths_05.exp @@ -1,5 +1,8 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile composer_paths_05.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/composer_paths.sh "" "../fixtures/no-lock-file" match_max 100000 @@ -10,9 +13,24 @@ expect "::debug::Unable to find composer.lock at '../fixtures/no-lock-file/compo ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at '../fixtures/no-lock-file/composer.json'\r ::debug::File composer.lock path computed as ''\r -::set-output name=command::*\r -::set-output name=cache-dir::*\r -::set-output name=json::../fixtures/no-lock-file/composer.json\r -::set-output name=lock::\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "command=*\r +cache-dir=*\r +json=../fixtures/no-lock-file/composer.json\r +lock=\r +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/composer_paths_06.exp b/tests/expect/composer_paths_06.exp index a0d2da7..60aa127 100755 --- a/tests/expect/composer_paths_06.exp +++ b/tests/expect/composer_paths_06.exp @@ -1,5 +1,8 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile composer_paths_06.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/composer_paths.sh "" "../fixtures/with-lock-file" match_max 100000 @@ -9,9 +12,24 @@ expect "::debug::Composer path is '*'\r ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at '../fixtures/with-lock-file/composer.json'\r ::debug::File composer.lock path computed as '../fixtures/with-lock-file/composer.lock'\r -::set-output name=command::*\r -::set-output name=cache-dir::*\r -::set-output name=json::../fixtures/with-lock-file/composer.json\r -::set-output name=lock::../fixtures/with-lock-file/composer.lock\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "command=*\r +cache-dir=*\r +json=../fixtures/with-lock-file/composer.json\r +lock=../fixtures/with-lock-file/composer.lock\r +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp index 7e96005..25d8be1 100755 --- a/tests/expect/composer_paths_08.exp +++ b/tests/expect/composer_paths_08.exp @@ -1,5 +1,8 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile composer_paths_08.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/composer_paths.sh "" "../fixtures/out-of-sync-lock" match_max 100000 @@ -9,9 +12,24 @@ expect "::debug::Composer path is '*'\r ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at '../fixtures/out-of-sync-lock/composer.json'\r ::debug::File composer.lock path computed as '../fixtures/out-of-sync-lock/composer.lock'\r -::set-output name=command::*\r -::set-output name=cache-dir::*\r -::set-output name=json::../fixtures/out-of-sync-lock/composer.json\r -::set-output name=lock::../fixtures/out-of-sync-lock/composer.lock\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "command=*\r +cache-dir=*\r +json=../fixtures/out-of-sync-lock/composer.json\r +lock=../fixtures/out-of-sync-lock/composer.lock\n +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index 953b5a0..6f30827 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -1,5 +1,8 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile composer_paths_09.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/composer_paths.sh "../fixtures/composer.phar" match_max 100000 @@ -9,9 +12,24 @@ expect "::debug::Composer path is '../fixtures/composer.phar'\r ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at './composer.json'\r ::debug::File composer.lock path computed as './composer.lock'\r -::set-output name=command::../fixtures/composer.phar\r -::set-output name=cache-dir::*\r -::set-output name=json::./composer.json\r -::set-output name=lock::./composer.lock\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "command=../fixtures/composer.phar\r +cache-dir=*\r +json=./composer.json\r +lock=./composer.lock\r +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/php_version_01.exp b/tests/expect/php_version_01.exp index eae2c7a..3fc75d2 100755 --- a/tests/expect/php_version_01.exp +++ b/tests/expect/php_version_01.exp @@ -1,12 +1,31 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile php_version_01.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/php_version.sh match_max 100000 expect "::debug::PHP path is '*'\r ::debug::PHP version is '*.*.*'\r -::set-output name=path::*\r -::set-output name=version::*.*.*\r " expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "path=*\r +version=*.*.*\r +\n +" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_01.exp b/tests/expect/should_cache_01.exp index 82e8bc3..7a5e9cd 100755 --- a/tests/expect/should_cache_01.exp +++ b/tests/expect/should_cache_01.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_01.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to ''" -expect -exact "::set-output name=do-cache::1" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=1\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_02.exp b/tests/expect/should_cache_02.exp index fb41936..80e809e 100755 --- a/tests/expect/should_cache_02.exp +++ b/tests/expect/should_cache_02.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_02.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "no" match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'no'" -expect -exact "::set-output name=do-cache::1" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=1\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_03.exp b/tests/expect/should_cache_03.exp index 160401b..959c0f6 100755 --- a/tests/expect/should_cache_03.exp +++ b/tests/expect/should_cache_03.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_03.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "yes" match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'yes'" -expect -exact "::set-output name=do-cache::0" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=0\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_04.exp b/tests/expect/should_cache_04.exp index 098c4c4..9315315 100755 --- a/tests/expect/should_cache_04.exp +++ b/tests/expect/should_cache_04.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_04.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "true" match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'true'" -expect -exact "::set-output name=do-cache::0" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=0\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_05.exp b/tests/expect/should_cache_05.exp index b26f3e0..8d714bd 100755 --- a/tests/expect/should_cache_05.exp +++ b/tests/expect/should_cache_05.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_05.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "1" match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to '1'" -expect -exact "::set-output name=do-cache::0" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=0\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_06.exp b/tests/expect/should_cache_06.exp index b767c5e..1b0f257 100755 --- a/tests/expect/should_cache_06.exp +++ b/tests/expect/should_cache_06.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_06.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "false" match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'false'" -expect -exact "::set-output name=do-cache::1" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=1\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_07.exp b/tests/expect/should_cache_07.exp index dbb1369..f92af5a 100755 --- a/tests/expect/should_cache_07.exp +++ b/tests/expect/should_cache_07.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_07.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "0" match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to '0'" -expect -exact "::set-output name=do-cache::1" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=1\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/expect/should_cache_08.exp b/tests/expect/should_cache_08.exp index 4032458..e952792 100755 --- a/tests/expect/should_cache_08.exp +++ b/tests/expect/should_cache_08.exp @@ -1,9 +1,26 @@ #!/usr/bin/env -S expect -f +set gitHubOutputFile should_cache_08.txt +set ::env(GITHUB_OUTPUT) $gitHubOutputFile + set timeout 3 spawn ../../bin/should_cache.sh "foo" match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'foo'" -expect -exact "::set-output name=do-cache::1" expect eof + +set fp [open $gitHubOutputFile r] +set fileData [read $fp] +close $fp + +set expectedValue "do-cache=1\n" + +if { $expectedValue != $fileData } { + puts "\nExpected output variable does not match. Received:\n" + puts $fileData + exit 1 +} + +# Clean up +file delete $gitHubOutputFile diff --git a/tests/fixtures/with-lock-file/composer.lock b/tests/fixtures/with-lock-file/composer.lock index e50b7ce..264ebfb 100644 --- a/tests/fixtures/with-lock-file/composer.lock +++ b/tests/fixtures/with-lock-file/composer.lock @@ -8,20 +8,24 @@ "packages": [ { "name": "ehime/hello-world", - "version": "1.0.3", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/ehime/hello-world.git", - "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094" + "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ehime/hello-world/zipball/033c81f43e6768e817219ab71c6073e6d5b8b094", - "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094", + "url": "https://api.github.com/repos/ehime/hello-world/zipball/b1c8cdd2c11272d8c5deec7816e51fa5374217c1", + "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "0.8.*", + "phpunit/phpunit": "4.3.5" }, "type": "library", "autoload": { @@ -30,18 +34,26 @@ } }, "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], "authors": [ { "name": "Jd Daniel", "email": "dodomeki@gmail.com" } ], - "description": "My first Composer project", + "description": "Sample Composer project", + "keywords": [ + "helloworld", + "sample", + "test" + ], "support": { "issues": "https://github.com/ehime/hello-world/issues", - "source": "https://github.com/ehime/hello-world/tree/1.0.3" + "source": "https://github.com/ehime/hello-world/tree/1.0.5" }, - "time": "2015-07-31T17:46:00+00:00" + "time": "2015-07-31T17:53:36+00:00" } ], "packages-dev": [], @@ -52,5 +64,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.0.0" } From 02b4d852c01c68c6eccea3bbd3f3e3b1b88a90bb Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 14 Oct 2022 09:29:30 -0400 Subject: [PATCH 02/10] Revert unintentional lock file change. --- tests/expect/composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/expect/composer.lock b/tests/expect/composer.lock index 4207769..f76f733 100644 --- a/tests/expect/composer.lock +++ b/tests/expect/composer.lock @@ -64,5 +64,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.2.0" } From 36abc218e4bd559c4b0b9dff2863d429592c6b41 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 14 Oct 2022 09:38:35 -0400 Subject: [PATCH 03/10] Change `command` to `composer_command`. Bash gets confused with the variable being named `command`. --- action.yml | 2 +- tests/expect/composer_paths_01.exp | 2 +- tests/expect/composer_paths_05.exp | 2 +- tests/expect/composer_paths_06.exp | 2 +- tests/expect/composer_paths_08.exp | 2 +- tests/expect/composer_paths_09.exp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index f76d9af..19e3b00 100644 --- a/action.yml +++ b/action.yml @@ -85,5 +85,5 @@ runs: "${{ inputs.composer-options }}" \ "${{ inputs.working-directory }}" \ "${{ steps.php.outputs.path }}" \ - "${{ steps.composer.outputs.command }}" \ + "${{ steps.composer.outputs.composer_command }}" \ "${{ steps.composer.outputs.lock }}" diff --git a/tests/expect/composer_paths_01.exp b/tests/expect/composer_paths_01.exp index a23e8b7..565a6ea 100755 --- a/tests/expect/composer_paths_01.exp +++ b/tests/expect/composer_paths_01.exp @@ -19,7 +19,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "command=*\r +set expectedValue "composer_command=*\r cache-dir=*\r json=./composer.json\r lock=./composer.lock\n diff --git a/tests/expect/composer_paths_05.exp b/tests/expect/composer_paths_05.exp index ae5bd69..34de0ed 100755 --- a/tests/expect/composer_paths_05.exp +++ b/tests/expect/composer_paths_05.exp @@ -20,7 +20,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "command=*\r +set expectedValue "composer_command=*\r cache-dir=*\r json=../fixtures/no-lock-file/composer.json\r lock=\r diff --git a/tests/expect/composer_paths_06.exp b/tests/expect/composer_paths_06.exp index 60aa127..c926c0d 100755 --- a/tests/expect/composer_paths_06.exp +++ b/tests/expect/composer_paths_06.exp @@ -19,7 +19,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "command=*\r +set expectedValue "composer_command=*\r cache-dir=*\r json=../fixtures/with-lock-file/composer.json\r lock=../fixtures/with-lock-file/composer.lock\r diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp index 25d8be1..3bdd5f4 100755 --- a/tests/expect/composer_paths_08.exp +++ b/tests/expect/composer_paths_08.exp @@ -19,7 +19,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "command=*\r +set expectedValue "composer_command=*\r cache-dir=*\r json=../fixtures/out-of-sync-lock/composer.json\r lock=../fixtures/out-of-sync-lock/composer.lock\n diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index 6f30827..eeaa044 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -19,7 +19,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "command=../fixtures/composer.phar\r +set expectedValue "composer_command=../fixtures/composer.phar\r cache-dir=*\r json=./composer.json\r lock=./composer.lock\r From ac7d89f77bb77b0fbb92364f2707f9c8ef468c99 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 14 Oct 2022 09:41:36 -0400 Subject: [PATCH 04/10] Undo `composer.lock` file changes within test fixtures. --- tests/fixtures/with-lock-file/composer.lock | 30 +++++++-------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/tests/fixtures/with-lock-file/composer.lock b/tests/fixtures/with-lock-file/composer.lock index 264ebfb..e50b7ce 100644 --- a/tests/fixtures/with-lock-file/composer.lock +++ b/tests/fixtures/with-lock-file/composer.lock @@ -8,24 +8,20 @@ "packages": [ { "name": "ehime/hello-world", - "version": "1.0.5", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/ehime/hello-world.git", - "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1" + "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ehime/hello-world/zipball/b1c8cdd2c11272d8c5deec7816e51fa5374217c1", - "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1", + "url": "https://api.github.com/repos/ehime/hello-world/zipball/033c81f43e6768e817219ab71c6073e6d5b8b094", + "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094", "shasum": "" }, "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "mockery/mockery": "0.8.*", - "phpunit/phpunit": "4.3.5" + "php": ">=5.3.0" }, "type": "library", "autoload": { @@ -34,26 +30,18 @@ } }, "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], "authors": [ { "name": "Jd Daniel", "email": "dodomeki@gmail.com" } ], - "description": "Sample Composer project", - "keywords": [ - "helloworld", - "sample", - "test" - ], + "description": "My first Composer project", "support": { "issues": "https://github.com/ehime/hello-world/issues", - "source": "https://github.com/ehime/hello-world/tree/1.0.5" + "source": "https://github.com/ehime/hello-world/tree/1.0.3" }, - "time": "2015-07-31T17:53:36+00:00" + "time": "2015-07-31T17:46:00+00:00" } ], "packages-dev": [], @@ -64,5 +52,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.2.0" } From 2254605eeef37e95cafe52db88667b1d4ebb2ce7 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 14 Oct 2022 09:50:28 -0400 Subject: [PATCH 05/10] Add some inline documentation to tests. --- tests/expect/cache_key_01.exp | 5 +++++ tests/expect/cache_key_02.exp | 5 +++++ tests/expect/cache_key_03.exp | 5 +++++ tests/expect/cache_key_04.exp | 5 +++++ tests/expect/cache_key_05.exp | 7 ++++++- tests/expect/cache_key_06.exp | 5 +++++ tests/expect/cache_key_07.exp | 5 +++++ tests/expect/composer_paths_01.exp | 1 + tests/expect/composer_paths_05.exp | 2 ++ tests/expect/composer_paths_06.exp | 2 ++ tests/expect/composer_paths_08.exp | 2 ++ tests/expect/composer_paths_09.exp | 2 ++ tests/expect/php_version_01.exp | 2 ++ tests/expect/should_cache_01.exp | 2 ++ tests/expect/should_cache_02.exp | 2 ++ tests/expect/should_cache_03.exp | 2 ++ tests/expect/should_cache_04.exp | 2 ++ tests/expect/should_cache_05.exp | 2 ++ tests/expect/should_cache_06.exp | 2 ++ tests/expect/should_cache_07.exp | 2 ++ tests/expect/should_cache_08.exp | 2 ++ 21 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tests/expect/cache_key_01.exp b/tests/expect/cache_key_01.exp index 3336041..d70c995 100755 --- a/tests/expect/cache_key_01.exp +++ b/tests/expect/cache_key_01.exp @@ -1,7 +1,10 @@ #!/usr/bin/env -S expect -f +# For testing environment variables written to GITHUB_ENV set gitHubEnvFile cache_key_01.txt set ::env(GITHUB_ENV) $gitHubEnvFile + +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile cache_key_output_01.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -14,6 +17,7 @@ expect -exact "::debug::Cache restore keys are 'php-composer-locked-'" expect eof +# Confirm environment variables. set fp [open $gitHubEnvFile r] set fileData [read $fp] close $fp @@ -29,6 +33,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_02.exp b/tests/expect/cache_key_02.exp index fe3fee8..69a2230 100755 --- a/tests/expect/cache_key_02.exp +++ b/tests/expect/cache_key_02.exp @@ -1,7 +1,10 @@ #!/usr/bin/env -S expect -f +# For testing environment variables written to GITHUB_ENV set gitHubEnvFile cache_key_02.txt set ::env(GITHUB_ENV) $gitHubEnvFile + +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile cache_key_output_02.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-lo expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-'" expect eof +# Confirm environment variables. set fp [open $gitHubEnvFile r] set fileData [read $fp] close $fp @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_03.exp b/tests/expect/cache_key_03.exp index 6315e7d..715f2c1 100755 --- a/tests/expect/cache_key_03.exp +++ b/tests/expect/cache_key_03.exp @@ -1,7 +1,10 @@ #!/usr/bin/env -S expect -f +# For testing environment variables written to GITHUB_ENV set gitHubEnvFile cache_key_03.txt set ::env(GITHUB_ENV) $gitHubEnvFile + +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile cache_key_output_03.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-lo expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-'" expect eof +# Confirm environment variables. set fp [open $gitHubEnvFile r] set fileData [read $fp] close $fp @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_04.exp b/tests/expect/cache_key_04.exp index b02dd09..f4efb28 100755 --- a/tests/expect/cache_key_04.exp +++ b/tests/expect/cache_key_04.exp @@ -1,7 +1,10 @@ #!/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 @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer---ignore- 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 @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_05.exp b/tests/expect/cache_key_05.exp index 6e416bf..112ba3f 100755 --- a/tests/expect/cache_key_05.exp +++ b/tests/expect/cache_key_05.exp @@ -1,8 +1,11 @@ #!/usr/bin/env -S expect -f +# For testing environment variables written to GITHUB_ENV set gitHubEnvFile cache_key_05.txt -set gitHubOutputFile cache_key_output_05.txt set ::env(GITHUB_ENV) $gitHubEnvFile + +# For testing outputs variables written to GITHUB_OUTPUT +set gitHubOutputFile cache_key_output_05.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile set timeout 3 @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'my-custom-key'" expect -exact "::debug::Cache restore keys are ''" expect eof +# Confirm environment variables. set fp [open $gitHubEnvFile r] set fileData [read $fp] close $fp @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_06.exp b/tests/expect/cache_key_06.exp index ecff5dd..d6bc2dd 100755 --- a/tests/expect/cache_key_06.exp +++ b/tests/expect/cache_key_06.exp @@ -1,7 +1,10 @@ #!/usr/bin/env -S expect -f +# For testing environment variables written to GITHUB_ENV set gitHubEnvFile cache_key_06.txt set ::env(GITHUB_ENV) $gitHubEnvFile + +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile cache_key_output_06.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'Linux-php-8.1.1-composer-locked-pa expect -exact "::debug::Cache restore keys are 'Linux-php-8.1.1-composer-locked-path/to/working/dir-'" expect eof +# Confirm environment variables. set fp [open $gitHubEnvFile r] set fileData [read $fp] close $fp @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_07.exp b/tests/expect/cache_key_07.exp index dc39d3f..b97f456 100755 --- a/tests/expect/cache_key_07.exp +++ b/tests/expect/cache_key_07.exp @@ -1,7 +1,10 @@ #!/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 @@ -13,6 +16,7 @@ expect -exact "::debug::Cache primary key is 'Windows-php-8.0.2-composer-locked- 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 @@ -28,6 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_01.exp b/tests/expect/composer_paths_01.exp index 565a6ea..3267c4a 100755 --- a/tests/expect/composer_paths_01.exp +++ b/tests/expect/composer_paths_01.exp @@ -15,6 +15,7 @@ expect "::debug::Composer path is '*'\r " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_05.exp b/tests/expect/composer_paths_05.exp index 34de0ed..78162b2 100755 --- a/tests/expect/composer_paths_05.exp +++ b/tests/expect/composer_paths_05.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile composer_paths_05.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -16,6 +17,7 @@ expect "::debug::Unable to find composer.lock at '../fixtures/no-lock-file/compo " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_06.exp b/tests/expect/composer_paths_06.exp index c926c0d..fa3fc97 100755 --- a/tests/expect/composer_paths_06.exp +++ b/tests/expect/composer_paths_06.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile composer_paths_06.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -15,6 +16,7 @@ expect "::debug::Composer path is '*'\r " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp index 3bdd5f4..637dbd7 100755 --- a/tests/expect/composer_paths_08.exp +++ b/tests/expect/composer_paths_08.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile composer_paths_08.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -15,6 +16,7 @@ expect "::debug::Composer path is '*'\r " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index eeaa044..a6819bd 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile composer_paths_09.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -15,6 +16,7 @@ expect "::debug::Composer path is '../fixtures/composer.phar'\r " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/php_version_01.exp b/tests/expect/php_version_01.exp index 3fc75d2..c21dd94 100755 --- a/tests/expect/php_version_01.exp +++ b/tests/expect/php_version_01.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile php_version_01.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -12,6 +13,7 @@ expect "::debug::PHP path is '*'\r " expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_01.exp b/tests/expect/should_cache_01.exp index 7a5e9cd..0d1e256 100755 --- a/tests/expect/should_cache_01.exp +++ b/tests/expect/should_cache_01.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_01.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to ''" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_02.exp b/tests/expect/should_cache_02.exp index 80e809e..04ec5b5 100755 --- a/tests/expect/should_cache_02.exp +++ b/tests/expect/should_cache_02.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_02.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'no'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_03.exp b/tests/expect/should_cache_03.exp index 959c0f6..c54f327 100755 --- a/tests/expect/should_cache_03.exp +++ b/tests/expect/should_cache_03.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_03.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'yes'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_04.exp b/tests/expect/should_cache_04.exp index 9315315..86dbdf9 100755 --- a/tests/expect/should_cache_04.exp +++ b/tests/expect/should_cache_04.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_04.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'true'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_05.exp b/tests/expect/should_cache_05.exp index 8d714bd..bc3b4c1 100755 --- a/tests/expect/should_cache_05.exp +++ b/tests/expect/should_cache_05.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_05.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to '1'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_06.exp b/tests/expect/should_cache_06.exp index 1b0f257..5291407 100755 --- a/tests/expect/should_cache_06.exp +++ b/tests/expect/should_cache_06.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_06.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'false'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_07.exp b/tests/expect/should_cache_07.exp index f92af5a..bdcc4f1 100755 --- a/tests/expect/should_cache_07.exp +++ b/tests/expect/should_cache_07.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_07.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to '0'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_08.exp b/tests/expect/should_cache_08.exp index e952792..97d3d71 100755 --- a/tests/expect/should_cache_08.exp +++ b/tests/expect/should_cache_08.exp @@ -1,5 +1,6 @@ #!/usr/bin/env -S expect -f +# For testing outputs variables written to GITHUB_OUTPUT set gitHubOutputFile should_cache_08.txt set ::env(GITHUB_OUTPUT) $gitHubOutputFile @@ -10,6 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'foo'" expect eof +# Confirm environment variables. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp From aeb24066b34b28c9984b1fa2965f7f5431e052f2 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 14 Oct 2022 09:53:20 -0400 Subject: [PATCH 06/10] Change missed `command` instance to `composer_command`. --- bin/composer_paths.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/composer_paths.sh b/bin/composer_paths.sh index ec866be..dc3d4f9 100755 --- a/bin/composer_paths.sh +++ b/bin/composer_paths.sh @@ -53,7 +53,7 @@ echo "::debug::${composer_version}" echo "::debug::Composer cache directory found at '${cache_dir}'" echo "::debug::File composer.json found at '${composer_json}'" echo "::debug::File composer.lock path computed as '${composer_lock}'" -echo "command=${composer_path}" >> "${GITHUB_OUTPUT}" +echo "composer_command=${composer_path}" >> "${GITHUB_OUTPUT}" echo "cache-dir=${cache_dir}" >> "${GITHUB_OUTPUT}" echo "json=${composer_json}" >> "${GITHUB_OUTPUT}" echo "lock=${composer_lock}" >> "${GITHUB_OUTPUT}" From dddb67347c13731b446ac421505ef4c0909fe99e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Nov 2022 19:52:38 +0100 Subject: [PATCH 07/10] `composer_paths.sh`: fix issue flagged by shellcheck --- bin/composer_paths.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/composer_paths.sh b/bin/composer_paths.sh index dc3d4f9..4d96a68 100755 --- a/bin/composer_paths.sh +++ b/bin/composer_paths.sh @@ -53,7 +53,9 @@ echo "::debug::${composer_version}" echo "::debug::Composer cache directory found at '${cache_dir}'" echo "::debug::File composer.json found at '${composer_json}'" echo "::debug::File composer.lock path computed as '${composer_lock}'" -echo "composer_command=${composer_path}" >> "${GITHUB_OUTPUT}" -echo "cache-dir=${cache_dir}" >> "${GITHUB_OUTPUT}" -echo "json=${composer_json}" >> "${GITHUB_OUTPUT}" -echo "lock=${composer_lock}" >> "${GITHUB_OUTPUT}" +{ + echo "composer_command=${composer_path}" + echo "cache-dir=${cache_dir}" + echo "json=${composer_json}" + echo "lock=${composer_lock}" +} >> "${GITHUB_OUTPUT}" From c0537c57fcf051b594a847038e0ff8a74e34b064 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Nov 2022 19:56:19 +0100 Subject: [PATCH 08/10] Tests: fix inline comments ... and make them slightly more descriptive. --- tests/expect/cache_key_01.exp | 2 +- tests/expect/cache_key_02.exp | 2 +- tests/expect/cache_key_03.exp | 2 +- tests/expect/cache_key_04.exp | 2 +- tests/expect/cache_key_05.exp | 2 +- tests/expect/cache_key_06.exp | 2 +- tests/expect/cache_key_07.exp | 2 +- tests/expect/composer_paths_01.exp | 2 +- tests/expect/composer_paths_05.exp | 2 +- tests/expect/composer_paths_06.exp | 2 +- tests/expect/composer_paths_08.exp | 2 +- tests/expect/composer_paths_09.exp | 2 +- tests/expect/php_version_01.exp | 2 +- tests/expect/should_cache_01.exp | 2 +- tests/expect/should_cache_02.exp | 2 +- tests/expect/should_cache_03.exp | 2 +- tests/expect/should_cache_04.exp | 2 +- tests/expect/should_cache_05.exp | 2 +- tests/expect/should_cache_06.exp | 2 +- tests/expect/should_cache_07.exp | 2 +- tests/expect/should_cache_08.exp | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/expect/cache_key_01.exp b/tests/expect/cache_key_01.exp index d70c995..ba9c4eb 100755 --- a/tests/expect/cache_key_01.exp +++ b/tests/expect/cache_key_01.exp @@ -33,7 +33,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_02.exp b/tests/expect/cache_key_02.exp index 69a2230..dee529b 100755 --- a/tests/expect/cache_key_02.exp +++ b/tests/expect/cache_key_02.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_03.exp b/tests/expect/cache_key_03.exp index 715f2c1..5b43fac 100755 --- a/tests/expect/cache_key_03.exp +++ b/tests/expect/cache_key_03.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_04.exp b/tests/expect/cache_key_04.exp index f4efb28..1020a8b 100755 --- a/tests/expect/cache_key_04.exp +++ b/tests/expect/cache_key_04.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_05.exp b/tests/expect/cache_key_05.exp index 112ba3f..0b6b27b 100755 --- a/tests/expect/cache_key_05.exp +++ b/tests/expect/cache_key_05.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_06.exp b/tests/expect/cache_key_06.exp index d6bc2dd..caeda76 100755 --- a/tests/expect/cache_key_06.exp +++ b/tests/expect/cache_key_06.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/cache_key_07.exp b/tests/expect/cache_key_07.exp index b97f456..1153892 100755 --- a/tests/expect/cache_key_07.exp +++ b/tests/expect/cache_key_07.exp @@ -32,7 +32,7 @@ if { $expectedValue != $fileData } { exit 1 } -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_01.exp b/tests/expect/composer_paths_01.exp index 3267c4a..3a59fc3 100755 --- a/tests/expect/composer_paths_01.exp +++ b/tests/expect/composer_paths_01.exp @@ -15,7 +15,7 @@ expect "::debug::Composer path is '*'\r " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_05.exp b/tests/expect/composer_paths_05.exp index 78162b2..63a6468 100755 --- a/tests/expect/composer_paths_05.exp +++ b/tests/expect/composer_paths_05.exp @@ -17,7 +17,7 @@ expect "::debug::Unable to find composer.lock at '../fixtures/no-lock-file/compo " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_06.exp b/tests/expect/composer_paths_06.exp index fa3fc97..8fb756e 100755 --- a/tests/expect/composer_paths_06.exp +++ b/tests/expect/composer_paths_06.exp @@ -16,7 +16,7 @@ expect "::debug::Composer path is '*'\r " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp index 637dbd7..29763e4 100755 --- a/tests/expect/composer_paths_08.exp +++ b/tests/expect/composer_paths_08.exp @@ -16,7 +16,7 @@ expect "::debug::Composer path is '*'\r " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index a6819bd..90d46c4 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -16,7 +16,7 @@ expect "::debug::Composer path is '../fixtures/composer.phar'\r " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/php_version_01.exp b/tests/expect/php_version_01.exp index c21dd94..7464da0 100755 --- a/tests/expect/php_version_01.exp +++ b/tests/expect/php_version_01.exp @@ -13,7 +13,7 @@ expect "::debug::PHP path is '*'\r " expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_01.exp b/tests/expect/should_cache_01.exp index 0d1e256..8cab46c 100755 --- a/tests/expect/should_cache_01.exp +++ b/tests/expect/should_cache_01.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to ''" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_02.exp b/tests/expect/should_cache_02.exp index 04ec5b5..91c04eb 100755 --- a/tests/expect/should_cache_02.exp +++ b/tests/expect/should_cache_02.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'no'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_03.exp b/tests/expect/should_cache_03.exp index c54f327..e86a442 100755 --- a/tests/expect/should_cache_03.exp +++ b/tests/expect/should_cache_03.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'yes'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_04.exp b/tests/expect/should_cache_04.exp index 86dbdf9..e52973c 100755 --- a/tests/expect/should_cache_04.exp +++ b/tests/expect/should_cache_04.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to 'true'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_05.exp b/tests/expect/should_cache_05.exp index bc3b4c1..15a46ff 100755 --- a/tests/expect/should_cache_05.exp +++ b/tests/expect/should_cache_05.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will NOT cache the dependencies because ignore-cache is set to '1'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_06.exp b/tests/expect/should_cache_06.exp index 5291407..b2c951a 100755 --- a/tests/expect/should_cache_06.exp +++ b/tests/expect/should_cache_06.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'false'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_07.exp b/tests/expect/should_cache_07.exp index bdcc4f1..ca239ca 100755 --- a/tests/expect/should_cache_07.exp +++ b/tests/expect/should_cache_07.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to '0'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp diff --git a/tests/expect/should_cache_08.exp b/tests/expect/should_cache_08.exp index 97d3d71..cf3f460 100755 --- a/tests/expect/should_cache_08.exp +++ b/tests/expect/should_cache_08.exp @@ -11,7 +11,7 @@ match_max 100000 expect -exact "::debug::We will cache the dependencies because ignore-cache is set to 'foo'" expect eof -# Confirm environment variables. +# Verify output variables have been set correctly. set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp From dc35f0391c84e654998e7c2a461a541591b6b24b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Nov 2022 19:57:40 +0100 Subject: [PATCH 09/10] Tests/composer_paths_09.exp: fix expectation Follow up to 237 which updated the `composer.phar` file, but missed the update needed to the test expectations. --- tests/expect/composer_paths_09.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index 90d46c4..1293839 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -9,7 +9,7 @@ spawn ../../bin/composer_paths.sh "../fixtures/composer.phar" match_max 100000 expect "::debug::Composer path is '../fixtures/composer.phar'\r -::debug::Composer version 2.2.2 2021-12-29 14:15:27\r +::debug::Composer version 2.2.18 2022-08-20 11:33:38\r ::debug::Composer cache directory found at '*'\r ::debug::File composer.json found at './composer.json'\r ::debug::File composer.lock path computed as './composer.lock'\r From fbe8889788c8823359f9468a3fce3ed456967305 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Nov 2022 19:59:07 +0100 Subject: [PATCH 10/10] Tests: fix test which need a pattern match Note: there may well be a way to not have the regex inline, which would make the code more readable, but I'm not familiar enough with Tcl and to be honest, I'm already darn glad that I managed to get it working ;-) Refs: * https://www.tcl.tk/man/tcl8.5/TclCmd/regexp.html * https://www.tcl.tk/man/tcl8.5/TclCmd/re_syntax.html --- tests/expect/composer_paths_01.exp | 8 +------- tests/expect/composer_paths_05.exp | 8 +------- tests/expect/composer_paths_06.exp | 8 +------- tests/expect/composer_paths_08.exp | 8 +------- tests/expect/composer_paths_09.exp | 8 +------- tests/expect/php_version_01.exp | 7 +------ 6 files changed, 6 insertions(+), 41 deletions(-) diff --git a/tests/expect/composer_paths_01.exp b/tests/expect/composer_paths_01.exp index 3a59fc3..95c6dfd 100755 --- a/tests/expect/composer_paths_01.exp +++ b/tests/expect/composer_paths_01.exp @@ -20,13 +20,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "composer_command=*\r -cache-dir=*\r -json=./composer.json\r -lock=./composer.lock\n -" - -if { $expectedValue != $fileData } { +if {[regexp {^composer_command=\S*\s*cache-dir=\S*\s*json=\./composer\.json\s*lock=./composer.lock\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1 diff --git a/tests/expect/composer_paths_05.exp b/tests/expect/composer_paths_05.exp index 63a6468..676476b 100755 --- a/tests/expect/composer_paths_05.exp +++ b/tests/expect/composer_paths_05.exp @@ -22,13 +22,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "composer_command=*\r -cache-dir=*\r -json=../fixtures/no-lock-file/composer.json\r -lock=\r -" - -if { $expectedValue != $fileData } { +if {[regexp {^composer_command=\S*\s*cache-dir=\S*\s*json=\.\./fixtures/no-lock-file/composer\.json\s*lock=\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1 diff --git a/tests/expect/composer_paths_06.exp b/tests/expect/composer_paths_06.exp index 8fb756e..7b176ee 100755 --- a/tests/expect/composer_paths_06.exp +++ b/tests/expect/composer_paths_06.exp @@ -21,13 +21,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "composer_command=*\r -cache-dir=*\r -json=../fixtures/with-lock-file/composer.json\r -lock=../fixtures/with-lock-file/composer.lock\r -" - -if { $expectedValue != $fileData } { +if {[regexp {^composer_command=\S*\s*cache-dir=\S*\s*json=\.\./fixtures/with-lock-file/composer\.json\s*lock=\.\./fixtures/with-lock-file/composer\.lock\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1 diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp index 29763e4..01fb397 100755 --- a/tests/expect/composer_paths_08.exp +++ b/tests/expect/composer_paths_08.exp @@ -21,13 +21,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "composer_command=*\r -cache-dir=*\r -json=../fixtures/out-of-sync-lock/composer.json\r -lock=../fixtures/out-of-sync-lock/composer.lock\n -" - -if { $expectedValue != $fileData } { +if {[regexp {^composer_command=\S*\s*cache-dir=\S*\s*json=\.\./fixtures/out-of-sync-lock/composer\.json\s*lock=\.\./fixtures/out-of-sync-lock/composer\.lock\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1 diff --git a/tests/expect/composer_paths_09.exp b/tests/expect/composer_paths_09.exp index 1293839..8575903 100755 --- a/tests/expect/composer_paths_09.exp +++ b/tests/expect/composer_paths_09.exp @@ -21,13 +21,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "composer_command=../fixtures/composer.phar\r -cache-dir=*\r -json=./composer.json\r -lock=./composer.lock\r -" - -if { $expectedValue != $fileData } { +if {[regexp {^composer_command=\.\./fixtures/composer\.phar\s*cache-dir=\S*\s*json=\./composer\.json\s*lock=\./composer\.lock\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1 diff --git a/tests/expect/php_version_01.exp b/tests/expect/php_version_01.exp index 7464da0..68f80f3 100755 --- a/tests/expect/php_version_01.exp +++ b/tests/expect/php_version_01.exp @@ -18,12 +18,7 @@ set fp [open $gitHubOutputFile r] set fileData [read $fp] close $fp -set expectedValue "path=*\r -version=*.*.*\r -\n -" - -if { $expectedValue != $fileData } { +if {[regexp {^path=\S*\s*version=\d*\.\d*\.\d*\s*$} $fileData] == 0} { puts "\nExpected output variable does not match. Received:\n" puts $fileData exit 1