nix_eval_jobs: Add timeouts to tests

Sometimes nix-eval-jobs would lock up indefinitely, so let's make it
fail fast in CI.

Also ignore test_json_global_error while we investigate.
This commit is contained in:
Zhaofeng Li 2022-02-04 20:58:17 -08:00
parent 856f82644e
commit 45b135c1b1
4 changed files with 71 additions and 1 deletions

60
Cargo.lock generated
View file

@ -141,6 +141,7 @@ dependencies = [
"lazy_static",
"libc",
"log",
"ntest",
"quit",
"regex",
"serde",
@ -520,6 +521,47 @@ dependencies = [
"winapi",
]
[[package]]
name = "ntest"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "984caf6c8aa869418ef88062fc685d07d50c04308e63f7eaff6a395b1f5aff33"
dependencies = [
"ntest_proc_macro_helper",
"ntest_test_cases",
"ntest_timeout",
]
[[package]]
name = "ntest_proc_macro_helper"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "115562228962147ca51748d19446a4261535a7b6a7b5ff02681e527dcefc22f7"
[[package]]
name = "ntest_test_cases"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c03e3201148714c580c5cf1ef68b1ed4039203068193197834a43503164b8237"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "ntest_timeout"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a870300c30d4224cb16022a4660fd8084d6cb4d29618563c3016b50cc757d1e7"
dependencies = [
"ntest_proc_macro_helper",
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "num_cpus"
version = "1.13.1"
@ -569,6 +611,15 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "proc-macro-crate"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
"toml",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -875,6 +926,15 @@ dependencies = [
"tokio-stream",
]
[[package]]
name = "toml"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde",
]
[[package]]
name = "unicode-bidi"
version = "0.3.7"

View file

@ -38,6 +38,7 @@ uuid = { version = "0.8.2", features = ["serde", "v4"] }
validator = { version = "0.14", features = ["derive"] }
[dev-dependencies]
ntest = "0.7.3"
tokio-test = "0.4.0"
[dependencies.tokio]

View file

@ -9,7 +9,7 @@ rustPlatform.buildRustPackage rec {
src = lib.cleanSource ./.;
};
cargoSha256 = "sha256-IENRzHvv9TdLj/aTkm/MZtUKSXjtNWrspOQGLK2xFoo=";
cargoSha256 = "sha256-kWxCc9UqM96Hqph4Aj39gv83PP6bNHripRTvMiucYFg=";
nativeBuildInputs = [ installShellFiles ];

View file

@ -223,10 +223,12 @@ pub fn get_pinned_nix_eval_jobs() -> Option<&'static str> {
mod tests {
use super::*;
use ntest::timeout;
use tokio_test::block_on;
use tokio_stream::StreamExt;
#[test]
#[timeout(30000)]
fn test_eval() {
let evaluator = NixEvalJobs::default();
let expr = r#"with import <nixpkgs> {}; { a = pkgs.hello; b = pkgs.bash; }"#.to_string();
@ -247,6 +249,7 @@ mod tests {
}
#[test]
#[timeout(30000)]
fn test_global_error() {
let evaluator = NixEvalJobs::default();
let expr = r#"gibberish"#.to_string();
@ -266,6 +269,7 @@ mod tests {
}
#[test]
#[timeout(30000)]
fn test_attribute_error() {
let evaluator = NixEvalJobs::default();
let expr = r#"with import <nixpkgs> {}; { a = pkgs.hello; b = throw "an error"; }"#.to_string();
@ -300,7 +304,12 @@ mod tests {
}
#[test]
#[timeout(30000)]
#[ignore]
fn test_json_global_error() {
// #[ignore]: nix-eval-jobs locks up when run in parallel to other tests
// cannot consistently reproduce and more investigation is needed
let evaluator = NixEvalJobs::default();
let expr = r#"with import <nixpkgs> {}; { a = pkgs.hello; b = pkgs.writeText "x" (import /sys/nonexistentfile); }"#.to_string();