Skip to content

Commit

Permalink
Merge pull request #119 from rust-secure-code/cargo-clean-in-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
Shnatsel committed May 1, 2023
2 parents 4712142 + e8b0523 commit 311f993
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ jobs:
profile: minimal
target: "x86_64-unknown-linux-musl"
- name: "Test on the native x86_64-unknown-linux-gnu"
run: cargo test --all-features
run: cargo test --all-features --workspace
- name: "Test cross-compiling to x86_64-unknown-linux-musl"
env:
AUDITABLE_TEST_TARGET: "x86_64-unknown-linux-musl"
run: cargo test --all-features
run: cargo test --all-features --workspace
- name: "Install the 32-bit GCC toolchain"
run: sudo apt-get install gcc-multilib
- name: "Test cross-compiling to i686-unknown-linux-gnu"
env:
AUDITABLE_TEST_TARGET: "i686-unknown-linux-gnu"
run: cargo test --all-features
run: cargo test --all-features --workspace
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true
- run: cargo test --all-features
- run: cargo test --all-features --workspace
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
override: true
target: "x86_64-pc-windows-gnu"
- name: "Test on the native x86_64-pc-windows-mscv"
run: cargo test --all-features
run: cargo test --all-features --workspace
- name: "Test when cross-compiling to x86_64-pc-windows-gnu"
env:
AUDITABLE_TEST_TARGET: "x86_64-pc-windows-gnu"
run: cargo test --all-features
run: cargo test --all-features --workspace
16 changes: 15 additions & 1 deletion cargo-auditable/tests/it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use cargo_metadata::{
// Path to cargo-auditable binary under test
const EXE: &str = env!("CARGO_BIN_EXE_cargo-auditable");

// Path to Cargo itself
const CARGO: &str = env!("CARGO");

/// Run cargo auditable with --manifest-path <cargo_toml_path arg> and extra args,
/// returning of map of workspace member names -> produced binaries (bin and cdylib)
/// Reads the AUDITABLE_TEST_TARGET environment variable to determine the target to compile for
Expand All @@ -27,12 +30,23 @@ fn run_cargo_auditable<P>(
where
P: AsRef<OsStr>,
{
// run `cargo clean` before performing the build,
// otherwise already built binaries will be used
// and we won't actually test the *current* version of `cargo auditable`
let status = Command::new(CARGO)
.arg("clean")
.arg("--manifest-path")
.arg(&cargo_toml_path)
.status()
.unwrap();
assert!(status.success(), "Failed to invoke `cargo clean`!");

let mut command = Command::new(EXE);
command
.arg("auditable")
.arg("build")
.arg("--manifest-path")
.arg(cargo_toml_path)
.arg(&cargo_toml_path)
// We'll parse these to get binary paths
.arg("--message-format=json")
.args(args);
Expand Down

0 comments on commit 311f993

Please sign in to comment.