Skip to content

Commit

Permalink
Put test 'args' at the end of the test command
Browse files Browse the repository at this point in the history
For test commands, 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.
  • Loading branch information
donatello authored and autarch committed Nov 11, 2024
1 parent 294bb6a commit 9e70970
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.16

- Arguments passed in the `args` parameter are now always last when executing `cargo`. This lets you
pass arguments to test binaries like `-- --something`. First reported by @mateocabanal (Mateo
Cabanal) as GH #12 and fully fixed by @donatello (Aditya Manthramurthy) in GH #30.

## 0.0.15 - 2024-09-21

- The `musl` packages are only installed when not cross-compiling.
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions test-project/src/bin2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ mod test {
fn test_something() {
assert_eq!(1, 1);
}

#[test]
#[ignore]
fn test_something_ignored() {
assert_eq!(2, 2);
}
}

0 comments on commit 9e70970

Please sign in to comment.