Skip to content

Commit

Permalink
Separate integration and package tests (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiwakaDev authored Jan 10, 2023
1 parent b7b84d0 commit cc8746c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ jobs:
-p swift-bridge-ir \
-p swift-bridge-macro \
-p swift-integration-tests
swift-package-test:
runs-on: macOS-11
timeout-minutes: 30

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Add rust targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin

- name: Run swift package tests
run: ./test-swift-packages.sh

integration-test:
runs-on: macOS-11
Expand All @@ -48,7 +65,7 @@ jobs:
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin

- name: Run integration tests
run: ./test-integration.sh
run: ./test-swift-rust-integration.sh

build-examples:
runs-on: macOS-11
Expand Down
39 changes: 39 additions & 0 deletions test-swift-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Swift package tests

set -e

export RUSTFLAGS="-D warnings"

# Change to the root directory of the Xcode project
cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P
THIS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
ROOT_DIR="$THIS_DIR"
cd $ROOT_DIR

# Make a temp directory
TEMP_DIR=$(mktemp -d)

# Delete the temp directory before the shell exits
trap 'rm -rf $TEMP_DIR' EXIT

# Copy directories related to all of the building and test running to the temp directory
for DIR in crates src examples SwiftRustIntegrationTestRunner
do
cp -r $DIR/ $TEMP_DIR/$DIR
done
cp Cargo.toml $TEMP_DIR
cd $TEMP_DIR/SwiftRustIntegrationTestRunner

# Build Rust
mkdir -p swift-package-rust-library-fixture/generated

./swift-package-rust-library-fixture/build.sh

# Create Swift Package
cargo run -p integration-test-create-swift-package

# Test Swift Package
cd swift-package-test-package
swift test
20 changes: 0 additions & 20 deletions test-integration.sh → test-swift-rust-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ ROOT_DIR="$THIS_DIR"
cd $ROOT_DIR

cd SwiftRustIntegrationTestRunner

# Delete previous generated files/folders
rm -r swift-package-rust-library-fixture/generated || true
rm -r swift-package-rust-library-fixture/MySwiftPackage || true
rm -r swift-package-rust-library-fixture/target || true
rm -r swift-package-test-package/.build || true

# Build Rust
mkdir swift-package-rust-library-fixture/generated

./swift-package-rust-library-fixture/build.sh

# Create Swift Package
cargo run -p integration-test-create-swift-package

# Test Swift Package
cd swift-package-test-package
swift test
cd ..

# If project files don't exist before Xcode begins building we get something like:
# error: Build input file cannot be found: '/path/to/Generated/SwiftBridgeCore.swift'
# So.. here we create empty versions of the files that will get generated during the
Expand Down

0 comments on commit cc8746c

Please sign in to comment.