Skip to content

Commit

Permalink
Add test for xcodeproj without Package.resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Sep 3, 2024
1 parent 0bd7b11 commit 125318e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 125318e

Please sign in to comment.