summaryrefslogtreecommitdiff
path: root/cli/tests/integration/coverage_tests.rs
diff options
context:
space:
mode:
authorLevente Kurusa <lkurusa@kernelstuff.org>2023-04-19 23:30:52 +0200
committerGitHub <noreply@github.com>2023-04-19 23:30:52 +0200
commitc33675588117aad0b8fabfa5816676d95ba8067e (patch)
tree49cfb08f08a1345b0381f347a393cb397a9c8ce5 /cli/tests/integration/coverage_tests.rs
parenta8ca09f78a26c16ed07bcffd23f1f9f486fa04e4 (diff)
fix(test/coverage): exclude test files (#18748)
Fixes: #18454
Diffstat (limited to 'cli/tests/integration/coverage_tests.rs')
-rw-r--r--cli/tests/integration/coverage_tests.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index 440d6b17e..79e15d95b 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -27,6 +27,13 @@ fn no_snaps() {
}
#[test]
+fn no_tests() {
+ no_tests_included("foo", "mts");
+ no_tests_included("foo", "ts");
+ no_tests_included("foo", "js");
+}
+
+#[test]
fn error_if_invalid_cache() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let deno_dir = context.deno_dir();
@@ -277,6 +284,53 @@ fn no_snaps_included(test_name: &str, extension: &str) {
output.assert_exit_code(0);
}
+fn no_tests_included(test_name: &str, extension: &str) {
+ let context = TestContext::default();
+ let tempdir = context.deno_dir();
+ let tempdir = tempdir.path().join("cov");
+
+ let output = context
+ .new_command()
+ .args_vec(vec![
+ "test".to_string(),
+ "--quiet".to_string(),
+ "--allow-read".to_string(),
+ format!("--coverage={}", tempdir.to_str().unwrap()),
+ format!("coverage/no_tests_included/{test_name}.test.{extension}"),
+ ])
+ .run();
+
+ output.assert_exit_code(0);
+ output.skip_output_check();
+
+ let output = context
+ .new_command()
+ .args_vec(vec![
+ "coverage".to_string(),
+ format!("{}/", tempdir.to_str().unwrap()),
+ ])
+ .split_output()
+ .run();
+
+ // Verify there's no "Check" being printed
+ assert!(output.stderr().is_empty());
+
+ let actual = util::strip_ansi_codes(output.stdout()).to_string();
+
+ let expected = fs::read_to_string(
+ util::testdata_path().join("coverage/no_tests_included/expected.out"),
+ )
+ .unwrap();
+
+ if !util::wildcard_match(&expected, &actual) {
+ println!("OUTPUT\n{actual}\nOUTPUT");
+ println!("EXPECTED\n{expected}\nEXPECTED");
+ panic!("pattern match failed");
+ }
+
+ output.assert_exit_code(0);
+}
+
#[test]
fn no_npm_cache_coverage() {
let context = TestContext::default();