Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions azure/stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parameters:
check_all_features: true
nightly_feature: ''
test_features: ''
test_args_raw: '--' # Defaults to a separator
test_arguments: '--' # Defaults to a separator

stages:
# the format here is so that we can have _two_ instances of this whole
Expand Down Expand Up @@ -59,7 +59,7 @@ stages:
single_threaded: ${{ parameters.single_threaded }}
nightly_feature: ${{ parameters.nightly_feature }}
features: ${{ parameters.test_features }}
raw_opts: ${{ parameters.test_args_raw }}
arguments: ${{ parameters.test_arguments }}
- stage: ${{ format('{0}style', parameters.prefix) }}
${{ if ne(parameters.prefix, '') }}:
displayName: ${{ format('Style linting ({0})', parameters.prefix) }}
Expand Down
6 changes: 3 additions & 3 deletions azure/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:
test_ignored: false
single_threaded: false
features: '' # empty feature list is == default
raw_opts: '--' # Defaults to the separator between cargo opts and libtest opts
arguments: '--' # Defaults to the separator between cargo opts and libtest opts

jobs:
- job: ${{ parameters.name }}
Expand Down Expand Up @@ -45,12 +45,12 @@ jobs:
- ${{ if eq('true', parameters.single_threaded) }}:
- bash: echo '##vso[task.setvariable variable=libtest_opts]$(libtest_opts) --test-threads=1'
# Run tests with the given options
- bash: cargo test $(cargo_opts) ${{ parameters.raw_opts }} $(libtest_opts)
- bash: cargo test $(cargo_opts) ${{ parameters.arguments }} $(libtest_opts)
displayName: Run tests
env:
${{ insert }}: ${{ parameters.envs }}
- ${{ if eq('true', parameters.test_ignored)}}:
- bash: cargo test $(cargo_opts) ${{ parameters.raw_opts }} $(libtest_opts) --ignored
- bash: cargo test $(cargo_opts) ${{ parameters.arguments }} $(libtest_opts) --ignored
displayName: Run ignored tests
env:
${{ insert }}: ${{ parameters.envs }}
Expand Down
8 changes: 4 additions & 4 deletions azure/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parameters:
single_threaded: false
nightly_feature: ''
features: ''
raw_opts: '--'
arguments: '--'

jobs:
- template: test.yml
Expand All @@ -17,7 +17,7 @@ jobs:
test_ignored: ${{ parameters.test_ignored }}
single_threaded: ${{ parameters.single_threaded }}
features: ${{ parameters.features }}
raw_opts: ${{ parameters.raw_opts }}
arguments: ${{ parameters.arguments }}
- template: test.yml
parameters:
name: cargo_test_beta
Expand All @@ -27,7 +27,7 @@ jobs:
test_ignored: ${{ parameters.test_ignored }}
single_threaded: ${{ parameters.single_threaded }}
features: ${{ parameters.features }}
raw_opts: ${{ parameters.raw_opts }}
arguments: ${{ parameters.arguments }}
- template: test.yml
parameters:
name: cargo_test_nightly
Expand All @@ -38,4 +38,4 @@ jobs:
test_ignored: ${{ parameters.test_ignored }}
single_threaded: ${{ parameters.single_threaded }}
features: "${{ parameters.features }},${{ parameters.nightly_feature }}"
raw_opts: ${{ parameters.raw_opts }}
arguments: ${{ parameters.arguments }}
19 changes: 19 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ fashion](https://doc.rust-lang.org/book/ch11-02-running-tests.html#running-tests
case for you, set this parameter to `true` and your tests will be run
with `--test-threads=1`.

### Custom Arguments

```yaml
stages:
- template: azure/stages.yml@templates
parameters:
test_arguments: <string> = '--'
```

If the pre-baked `cargo test` parameters are not extensible enough for your
use case, (for example, if you need to pass unstable `-Z` options) you can
pass `cargo test` custom arguments that are used *in addition* to any others
set by parameters. This parameter has a syntax:

`<cargo test args> -- <libtest args>`

However, even if you do not include any custom libtest arguments,
you still **must** include a trailing `--`.

### Disable checking all features

```yaml
Expand Down
4 changes: 3 additions & 1 deletion docs/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ to run [additional setup
steps](configuration.md#additional-setup-steps). You can also pass
`features` and/or `nightly_feature` to include additional cargo features
when running the tests. `nightly_feature` will only be included on runs
with the nightly compiler. See the [test docs](#test) for details.
with the nightly compiler. See the [test docs](#test) for details.

### Test

Expand All @@ -173,6 +173,7 @@ parameters:
test_ignored: <bool> = false
single_threaded: <bool> = false
features: <string> = ''
arguments: <string> = '--'
envs:
NAME: value
setup:
Expand All @@ -192,6 +193,7 @@ set `test_ignored: true`. To run tests with
[`--test-threads=1`](https://doc.rust-lang.org/book/ch11-02-running-tests.html#running-tests-in-parallel-or-consecutively),
set `single_threaded: true`. To run tests with particular features
enabled, pass `features: "feat1,feat2,subcrate/feat3"`.
To include arbitrary `cargo test` arguments, pass `arguments: <test args -- libtest args>`, but note that you must always include the `--`, even if you add no libtest args.

### Style

Expand Down