plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


2910207 — Peter John 2026-11-10T23:12:53+05:30
plum test: a --filter that matches no test fails
compiler/cli/src/main.rs CHANGED
@@ -552,8 +552,9 @@ fn testOnce(paths: &[std::path::PathBuf], lib_path: &std::path::Path, options: &
552
552
  // A sweep's worker (see `runSweepParallel`) reads the counts from this line.
553
553
  if std::env::var_os(TEST_CHILD_ENV).is_some() {
554
554
  println!("{COUNTS_MARK}{passed} {failed}");
555
+ return Ok(failed == 0);
555
556
  }
556
- return Ok(failed == 0);
557
+ return Ok(failed == 0 && filterMatched(options, passed + failed));
557
558
  }
558
559
  }
559
560
 
@@ -615,7 +616,18 @@ fn testOnce(paths: &[std::path::PathBuf], lib_path: &std::path::Path, options: &
615
616
  files.len() - files_failed,
616
617
  files.len()
617
618
  );
619
+ Ok(files_failed == 0 && filterMatched(options, total_passed + total_failed))
620
+ }
621
+
622
+ /// A `--filter` that ran no test is an error (a misspelt name would otherwise pass).
623
+ fn filterMatched(options: &TestOptions, ran: usize) -> bool {
624
+ match &options.filter {
618
- Ok(files_failed == 0)
625
+ Some(f) if ran == 0 => {
626
+ eprintln!("error: no test name contains `{f}`");
627
+ false
628
+ }
629
+ _ => true,
630
+ }
619
631
  }
620
632
 
621
633
  /// Set on a sweep's child `plum test <file>`: it then prints its counts on a `COUNTS_MARK` line.
compiler/cli/tests/cli/test_scope_test.rs CHANGED
@@ -94,6 +94,21 @@ fn filterRunsOnlyMatchingTests() {
94
94
  assert!(out.contains("1 passed, 0 failed") && out.contains("no tests in"), "{out}");
95
95
  }
96
96
 
97
+ /// A `--filter` that matches no test fails, in a file and in a sweep: a misspelt name
98
+ /// must not pass by running nothing.
99
+ #[test]
100
+ fn aFilterThatMatchesNothingFails() {
101
+ let dir = scratch("filter_none");
102
+ std::fs::write(dir.join("a.plum"), TWO).unwrap();
103
+ std::fs::write(dir.join("b.plum"), TWO).unwrap();
104
+ for target in [dir.join("a.plum"), dir.to_path_buf()] {
105
+ let out = Command::new(plumBin()).current_dir(dir.path()).args(["test", "--filter", "zzz"]).arg(&target).output().unwrap();
106
+ let err = String::from_utf8_lossy(&out.stderr);
107
+ assert!(!out.status.success(), "{target:?}: {err}");
108
+ assert!(err.contains("no test name contains `zzz`"), "{target:?}: {err}");
109
+ }
110
+ }
111
+
97
112
  /// `plum check` reports a type error with its file and fails; clean files pass.
98
113
  #[test]
99
114
  fn checkReportsTypeErrorsWithoutRunning() {