From 125318e5c57645578a8bfad630581f39c066156b Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 3 Sep 2024 15:09:05 +1000 Subject: [PATCH] Add test for `xcodeproj` without `Package.resolved` --- .buildkite/pipeline.yml | 3 ++ .../test_scripts/test_project_no_package.sh | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 tests/install_swiftpm_dependencies/test_scripts/test_project_no_package.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index c37f163..3967521 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -29,6 +29,9 @@ steps: - label: ":xcode: Xcode Project - Explicit" command: tests/install_swiftpm_dependencies/test_scripts/test_project_explicit.sh + - label: ":xcode: Xcode Project - No Package.resolved" + command: tests/install_swiftpm_dependencies/test_scripts/test_project_no_package.sh + - label: ":xcode: Xcode Workspace - Autodetect" command: tests/install_swiftpm_dependencies/test_scripts/test_workspace_automatic.sh diff --git a/tests/install_swiftpm_dependencies/test_scripts/test_project_no_package.sh b/tests/install_swiftpm_dependencies/test_scripts/test_project_no_package.sh new file mode 100755 index 0000000..5914041 --- /dev/null +++ b/tests/install_swiftpm_dependencies/test_scripts/test_project_no_package.sh @@ -0,0 +1,37 @@ +#!/bin/bash -eu + +set -o pipefail + +source "$(dirname "${BASH_SOURCE[0]}")/set_up_environment.sh" + +echo "--- :computer: Jump to test folder" +pushd "$TESTS_LOCATION/../project" + +echo "--- :computer: Generate project" +brew install xcodegen +make + +# Notice we do not set up the fixture Package.resolved. +# As such, we expect the call to the plugin to fail. + +echo "--- :wrench: Run install_swiftpm_dependencies" +PROJECT=Demo.xcodeproj +LOGS_PATH=logs +set +e +install_swiftpm_dependencies --project $PROJECT 2>&1 | tee "$LOGS_PATH" +CMD_EXIT_STATUS=$? +set -e + +if [[ $CMD_EXIT_STATUS -eq 0 ]]; then + echo "^^^ install_swiftpm_dependencies unexpectedly succeeded without a Package.resolved in the project folder!" + exit 1 +else + EXPECTED="Unable to find \`Package.resolved\` file ($PROJECT/project.xcworkspace/xcshareddata/swiftpm/Package.resolved)" + if grep -qF "$EXPECTED" "$LOGS_PATH"; then + echo "^^^ +++ install_swiftpm_dependencies failed as expected because there is no Package.resolved in the project folder." + else + echo "+++ install_swiftpm_dependencies failed, but the message it printed is not what we expected." + echo "Expected: $EXPECTED" + echo "Got: $(cat $LOGS_PATH)" + fi +fi