From cf2f29fd86299425306ff2b33172a76bd5301c13 Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Sat, 11 Jan 2025 12:49:28 -0600 Subject: [PATCH] Run tests twice, one for main crate and once for subcrate It seems like restoring the cache for subcrate deletes sometimes removes the compiled binaries for the parent crate. I'm not sure what's going on here, as it doesn't happen every time. --- .github/workflows/test.yml | 17 +++++++++++++++-- run-tests/src/main.rs | 33 +++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b665cc..b5c23cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -262,6 +262,18 @@ jobs: target: ${{ matrix.platform.target }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strip: true + - name: Check binary and cross for main crate on ${{ matrix.platform.platform_name }} + shell: bash + run: | + set -e + set -x + cargo run --manifest-path ./run-tests/Cargo.toml -- \ + --checkout-root "$PWD" \ + --target "${{ matrix.platform.target }}" \ + --expect-file-re "${{ matrix.platform.expect_file_re }}" \ + --expect-cross-version "${{ matrix.platform.expect_cross_version }}" \ + ${{ matrix.platform.expect_cross }} \ + ${{ matrix.platform.expect_stripped }} - name: Dump tree shell: bash run: | @@ -296,7 +308,7 @@ jobs: set -x sudo apt-get install -y tree tree . - - name: Check binary and cross on ${{ matrix.platform.platform_name }} + - name: Check binary and cross for subcrate on ${{ matrix.platform.platform_name }} shell: bash run: | set -e @@ -307,7 +319,8 @@ jobs: --expect-file-re "${{ matrix.platform.expect_file_re }}" \ --expect-cross-version "${{ matrix.platform.expect_cross_version }}" \ ${{ matrix.platform.expect_cross }} \ - ${{ matrix.platform.expect_stripped }} + ${{ matrix.platform.expect_stripped }} \ + --is-subcrate test-validate-inputs: name: Test validate-inputs diff --git a/run-tests/src/main.rs b/run-tests/src/main.rs index 66f83b5..66e69df 100644 --- a/run-tests/src/main.rs +++ b/run-tests/src/main.rs @@ -24,6 +24,8 @@ struct Args { expect_cross_version: Option, #[arg(long)] expect_stripped: bool, + #[arg(long)] + is_subcrate: bool, } fn main() { @@ -39,24 +41,27 @@ fn main() { ); let checkout_root_path = PathBuf::from(args.checkout_root); - let bin_paths = vec![ - checkout_root_path - .join("target") - .join(&args.target) - .join("debug") - .join("bin1"), - checkout_root_path - .join("target") - .join(&args.target) - .join("debug") - .join("bin2"), - checkout_root_path + let bin_paths = if args.is_subcrate { + vec![checkout_root_path .join("subcrate") .join("target") .join(&args.target) .join("debug") - .join("subcrate"), - ]; + .join("subcrate")] + } else { + vec![ + checkout_root_path + .join("target") + .join(&args.target) + .join("debug") + .join("bin1"), + checkout_root_path + .join("target") + .join(&args.target) + .join("debug") + .join("bin2"), + ] + }; for mut bin_path in bin_paths { if cfg!(windows) {