diff --git a/azure/stages.yml b/azure/stages.yml index ede925f..15f3444 100644 --- a/azure/stages.yml +++ b/azure/stages.yml @@ -10,6 +10,7 @@ parameters: check_all_features: true nightly_feature: '' test_features: '' + test_arguments: '--' # Defaults to a separator stages: # the format here is so that we can have _two_ instances of this whole @@ -58,6 +59,7 @@ stages: single_threaded: ${{ parameters.single_threaded }} nightly_feature: ${{ parameters.nightly_feature }} features: ${{ parameters.test_features }} + arguments: ${{ parameters.test_arguments }} - stage: ${{ format('{0}style', parameters.prefix) }} ${{ if ne(parameters.prefix, '') }}: displayName: ${{ format('Style linting ({0})', parameters.prefix) }} diff --git a/azure/test.yml b/azure/test.yml index 47cedfe..1b5fb38 100644 --- a/azure/test.yml +++ b/azure/test.yml @@ -7,6 +7,7 @@ parameters: test_ignored: false single_threaded: false features: '' # empty feature list is == default + arguments: '--' # Defaults to the separator between cargo opts and libtest opts jobs: - job: ${{ parameters.name }} @@ -24,9 +25,11 @@ jobs: vmImage: macOS-10.14 Windows: vmImage: windows-2019 - ${{ if ne('true', parameters.cross) }}: - variables: + variables: + ${{ if ne('true', parameters.cross) }}: vmImage: ubuntu-16.04 + cargo_opts: '' + libtest_opts: '' pool: vmImage: $(vmImage) steps: @@ -34,23 +37,21 @@ jobs: parameters: rust: ${{ parameters.rust }} setup: ${{ parameters.setup }} - - ${{ if ne('true', parameters.single_threaded) }}: - - script: cargo test --all --features "${{ parameters.features }}" - displayName: Run tests - env: - ${{ insert }}: ${{ parameters.envs }} + # Cargo options go here + - bash: echo '##vso[task.setvariable variable=cargo_opts]$(cargo_opts) --all' + - ${{ if eq(true, parameters.features)}}: + - bash: echo '##vso[task.setvariable variable=cargo_opts]$(cargo_opts) --features "${{ parameters.features }}"' + # Libtest options go here - ${{ if eq('true', parameters.single_threaded) }}: - - script: cargo test --all --features "${{ parameters.features }}" -- --test-threads=1 - displayName: Run tests (single-threaded) - env: - ${{ insert }}: ${{ parameters.envs }} - - ${{ if and(eq('true', parameters.test_ignored), ne('true', parameters.single_threaded)) }}: - - script: cargo test --all --features "${{ parameters.features }}" -- --ignored + - 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.arguments }} $(libtest_opts) + displayName: Run tests + env: + ${{ insert }}: ${{ parameters.envs }} + - ${{ if eq('true', parameters.test_ignored)}}: + - bash: cargo test $(cargo_opts) ${{ parameters.arguments }} $(libtest_opts) --ignored displayName: Run ignored tests env: ${{ insert }}: ${{ parameters.envs }} - - ${{ if and(eq('true', parameters.test_ignored), eq('true', parameters.single_threaded)) }}: - - script: cargo test --all --features "${{ parameters.features }}" -- --ignored --test-threads=1 - displayName: Run ignored tests (single-threaded) - env: - ${{ insert }}: ${{ parameters.envs }} + diff --git a/azure/tests.yml b/azure/tests.yml index bbab2de..0560a76 100644 --- a/azure/tests.yml +++ b/azure/tests.yml @@ -5,6 +5,7 @@ parameters: single_threaded: false nightly_feature: '' features: '' + arguments: '--' jobs: - template: test.yml @@ -16,6 +17,7 @@ jobs: test_ignored: ${{ parameters.test_ignored }} single_threaded: ${{ parameters.single_threaded }} features: ${{ parameters.features }} + arguments: ${{ parameters.arguments }} - template: test.yml parameters: name: cargo_test_beta @@ -25,6 +27,7 @@ jobs: test_ignored: ${{ parameters.test_ignored }} single_threaded: ${{ parameters.single_threaded }} features: ${{ parameters.features }} + arguments: ${{ parameters.arguments }} - template: test.yml parameters: name: cargo_test_nightly @@ -35,3 +38,4 @@ jobs: test_ignored: ${{ parameters.test_ignored }} single_threaded: ${{ parameters.single_threaded }} features: "${{ parameters.features }},${{ parameters.nightly_feature }}" + arguments: ${{ parameters.arguments }} diff --git a/docs/configuration.md b/docs/configuration.md index 3aefd15..3a32f17 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -101,6 +101,26 @@ 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: = '--' +``` + +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: + +` -- ` + +Note that even if you include no libtest arguments, you must still include +a trailing `--` so that any libtest arguments passed by other +configuration options (such as `single_threaded`) will still work correctly. + ### Disable checking all features ```yaml diff --git a/docs/custom.md b/docs/custom.md index 2ce27c0..0fb2853 100644 --- a/docs/custom.md +++ b/docs/custom.md @@ -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 @@ -173,6 +173,7 @@ parameters: test_ignored: = false single_threaded: = false features: = '' + arguments: = '--' envs: NAME: value setup: @@ -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: `, but note that you must always include the `--`, even if you add no libtest args. ### Style