From 9b665082bf60aa18be9cd652362fd5f1ad510774 Mon Sep 17 00:00:00 2001 From: reuben olinsky Date: Fri, 25 Oct 2024 16:59:12 -0700 Subject: [PATCH] feat: start adding os-specific integration tests --- .github/workflows/ci.yaml | 45 ++++++++++++++++++++++++-- brush-shell/tests/compat_tests.rs | 4 +++ brush-shell/tests/completion_tests.rs | 2 ++ brush-shell/tests/interactive_tests.rs | 4 +++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bfa82041..bfc0ddc2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,11 +93,11 @@ jobs: - name: "Build (native)" if: ${{ matrix.target == '' }} - run: cargo build --release + run: cargo build --release --all-targets - name: "Build (cross)" if: ${{ matrix.target != '' }} - run: cross build --release --target=${{ matrix.target }} + run: cross build --release --all-targets --target=${{ matrix.target }} - name: "Upload binaries" uses: actions/upload-artifact@v4 @@ -105,6 +105,12 @@ jobs: name: binaries-${{ matrix.arch }}-${{ matrix.os }} path: target/${{ matrix.target }}/release/${{ matrix.binary_name }} + - name: "Upload integration test binaries" + uses: actions/upload-artifact@v4 + with: + name: integration-tests-${{ matrix.arch }}-${{ matrix.os }} + path: target/${{ matrix.target }}/release/deps/brush_*_tests-* + # Test functional correctness test: strategy: @@ -317,3 +323,38 @@ jobs: pr/benchmarks.txt main/benchmarks.txt benchmark-results.md + + # Test release binary on a variety of OS platforms. + os-tests: + name: "OS tests" + runs-on: ubuntu-latest + container: fedora:latest + needs: build + steps: + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: binaries-x86_64-linux + path: binaries + + - name: Download integration test binaries + uses: actions/download-artifact@v4 + with: + name: integration-tests-x86_64-linux + path: binaries + + - name: Preview downloads + run: ls -l binaries + + - name: Run tests + run: | + export CARGO_TARGET_DIR=binaries + export CARGO_BIN_EXE_brush=binaries/brush + + result=0 + for test_name in binaries/*tests*; do + echo "Running test: ${test_name}" + ${test_name} || result=$? + done + + exit ${result} diff --git a/brush-shell/tests/compat_tests.rs b/brush-shell/tests/compat_tests.rs index d1d4c040..78bd7e26 100644 --- a/brush-shell/tests/compat_tests.rs +++ b/brush-shell/tests/compat_tests.rs @@ -1,5 +1,9 @@ //! The test harness for brush shell integration tests. +// Only compile this for Unix-like platforms (Linux, macOS) because they have an oracle to compare +// against. +#![cfg(unix)] + use anyhow::{Context, Result}; use assert_fs::fixture::{FileWriteStr, PathChild}; use clap::Parser; diff --git a/brush-shell/tests/completion_tests.rs b/brush-shell/tests/completion_tests.rs index bc779cdc..7cf98e06 100644 --- a/brush-shell/tests/completion_tests.rs +++ b/brush-shell/tests/completion_tests.rs @@ -1,3 +1,5 @@ +//! Completion integration tests for brush shell. + // For now, only compile this for Linux. #![cfg(target_os = "linux")] #![allow(clippy::panic_in_result_fn)] diff --git a/brush-shell/tests/interactive_tests.rs b/brush-shell/tests/interactive_tests.rs index 95e8e300..6a4973f5 100644 --- a/brush-shell/tests/interactive_tests.rs +++ b/brush-shell/tests/interactive_tests.rs @@ -1,3 +1,7 @@ +//! Interactive integration tests for brush shell + +// For now, only compile this for Unix-like platforms (Linux, macOS). +#![cfg(unix)] #![allow(clippy::panic_in_result_fn)] use anyhow::Context;