From 7bfbce75f5e7f7db320c1c652cbf09815fc77793 Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Sun, 3 Nov 2024 16:24:56 -0800 Subject: [PATCH] Put test 'args' at the end of the test command For test command, there can be arguments passed to the test binary like `-- --ignored` or `-- --test-threads=1`. For these cases to work properly, the `args` parameter needs to be added to the end of the 'test' command. --- .github/workflows/test.yml | 10 ++++++++++ action.yml | 4 ++-- test-project/src/bin2.rs | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2e188f..75726f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -243,6 +243,16 @@ jobs: target: ${{ matrix.platform.target }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ matrix.platform.can_test }} + - name: Run test command with args + uses: ./ + with: + command: test + cross-version: ${{ matrix.platform.cross-version }} + cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} + target: ${{ matrix.platform.target }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + args: "-- --ignored" + if: ${{ matrix.platform.can_test }} - name: Run build command uses: ./ with: diff --git a/action.yml b/action.yml index 545b70a..1b37f69 100644 --- a/action.yml +++ b/action.yml @@ -95,7 +95,7 @@ runs: working-directory: ${{ inputs.working-directory }} shell: bash run: | - ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }} + ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }} if: inputs.command != 'build' && runner.os != 'Windows' # We want to run in Powershell on Windows to make sure we compile in a # native Windows environment. Some things won't compile properly under @@ -105,7 +105,7 @@ runs: working-directory: ${{ inputs.working-directory }} shell: powershell run: | - & ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }} + & ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }} if: inputs.command != 'build' && runner.os == 'Windows' - name: Build binary (*nix) working-directory: ${{ inputs.working-directory }} diff --git a/test-project/src/bin2.rs b/test-project/src/bin2.rs index b80f5b7..f9026b7 100644 --- a/test-project/src/bin2.rs +++ b/test-project/src/bin2.rs @@ -8,4 +8,10 @@ mod test { fn test_something() { assert_eq!(1, 1); } + + #[test] + #[ignore] + fn test_something_ignored() { + assert_eq!(2, 2); + } }