diff --git a/ci/common.yml b/ci/common.yml index b407efec..e64e1871 100644 --- a/ci/common.yml +++ b/ci/common.yml @@ -1,5 +1,5 @@ variables: - rustVersion: nightly-2019-10-13 + rustVersion: nightly-2019-11-05 linuxPrestep: | sudo apt-get update && sudo apt-get install -y \ diff --git a/ci/jobs/cargo-test.yml b/ci/jobs/cargo-test.yml index aad85610..45b3f0ba 100644 --- a/ci/jobs/cargo-test.yml +++ b/ci/jobs/cargo-test.yml @@ -25,6 +25,7 @@ parameters: no-default-features: false # Do not activate the `default` feature # parameters from libtest `cargo test -- --help` + # TODO: specifying a portion of these does not work test_flags: include-ignored: false # Run ignored and not ignored tests ignored: false # Run only ignored tests @@ -41,6 +42,7 @@ parameters: quite: false # Display one character per test instead of one line. # Alias to --format=terse exact: false # Exactly match filters rather than by substring + ensure-time: true # Treat excess of the test execution time limit as error. (unstable) color: '' # auto|always|never # Configure coloring of output: auto = colorize if # stdout is a tty and tests are run on serially @@ -50,7 +52,7 @@ parameters: # Configure formatting of output: pretty = Print verbose # output; terse = Display one character per test; json = # Output a json document - Z: [] # unstable-options Enable nightly-only flags: unstable-options = Allow + Z: ['unstable-options'] # unstable-options Enable nightly-only flags: unstable-options = Allow # use of experimental features @@ -66,6 +68,11 @@ jobs: variables: check_flags: '' test_build_flags: '' + + # Time limits for `--ensure-time` + RUST_TEST_TIME_UNIT: '2,10' + RUST_TEST_TIME_INTEGRATION: '4,30' + RUST_TEST_TIME_DOCTEST: '8,40' steps: # Custom pre steps: - script: $(prepareScript) @@ -141,6 +148,10 @@ jobs: enabled: ${{ parameters.test_flags['exact'] }} displayName: "[cli flag modify]Exactly match filters rather than by substring" + - script: echo '##vso[task.setvariable variable=check_flags]$(check_flags) --ensure-time' + enabled: ${{ parameters.test_flags['ensure-time'] }} + displayName: "[cli flag modify]Treat excess of the test execution time limit as error" + - script: echo "##vso[task.setvariable variable=check_flags]$(check_flags) --color ${{ parameters.test_flags['color'] }}" enabled: ${{ ne(parameters.test_flags['color'], '') }} displayName: "[cli flag modify] Configure coloring of output: ${{ parameters.test_flags['color'] }}" @@ -150,7 +161,7 @@ jobs: displayName: "[cli flag modify] Configure formatting of output: ${{ parameters.test_flags['format'] }}" - ${{ each z in parameters.test_flags['Z'] }}: - - script: echo '##vso[task.setvariableV variable=check_flags]$(check_flags) --Z ${{ z }}' + - script: echo '##vso[task.setvariable variable=check_flags]$(check_flags) -Z ${{ z }}' displayName: "[cli flag modify] unstable-option: ${{ z }}" # ********************************************************************************************* diff --git a/tcw3/pal/tests/common/mod.rs b/tcw3/pal/tests/common/mod.rs new file mode 100644 index 00000000..beee87cc --- /dev/null +++ b/tcw3/pal/tests/common/mod.rs @@ -0,0 +1,9 @@ +use std::time::Duration; + +pub fn set_timelimit_default() { + std::thread::spawn(|| { + std::thread::sleep(Duration::from_secs(30)); + eprintln!("!!! Time limit exceeed."); + std::process::abort(); + }); +} diff --git a/tcw3/pal/tests/futures.rs b/tcw3/pal/tests/futures.rs index 925f553f..3726f453 100644 --- a/tcw3/pal/tests/futures.rs +++ b/tcw3/pal/tests/futures.rs @@ -2,8 +2,11 @@ use futures::{channel::oneshot::channel, task::LocalSpawnExt}; use std::{env::var_os, time::Duration}; use tcw3_pal::{prelude::Wm as _, prelude::*, Wm}; +mod common; + fn main() { env_logger::init(); + common::set_timelimit_default(); if let Some(value) = var_os("ST_SKIP_NATIVE_BACKEND_TESTS") { if !value.is_empty() && value != "0" { diff --git a/tcw3/pal/tests/timer.rs b/tcw3/pal/tests/timer.rs index 993dab51..45e35d8c 100644 --- a/tcw3/pal/tests/timer.rs +++ b/tcw3/pal/tests/timer.rs @@ -6,8 +6,11 @@ use std::{ }; use tcw3_pal::{prelude::Wm as _, prelude::*, Wm}; +mod common; + fn main() { env_logger::init(); + common::set_timelimit_default(); if let Some(value) = var_os("ST_SKIP_NATIVE_BACKEND_TESTS") { if !value.is_empty() && value != "0" {