summaryrefslogtreecommitdiff
path: root/cli/tools
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/tools
parenta8ca09f78a26c16ed07bcffd23f1f9f486fa04e4 (diff)
fix(test/coverage): exclude test files (#18748)
Fixes: #18454
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/coverage/mod.rs5
-rw-r--r--cli/tools/test.rs2
2 files changed, 5 insertions, 2 deletions
diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs
index 029778243..d3044a716 100644
--- a/cli/tools/coverage/mod.rs
+++ b/cli/tools/coverage/mod.rs
@@ -6,6 +6,7 @@ use crate::args::Flags;
use crate::colors;
use crate::proc_state::ProcState;
use crate::tools::fmt::format_json;
+use crate::tools::test::is_supported_test_path;
use crate::util::fs::FileCollector;
use crate::util::text_encoding::source_map_from_code;
@@ -27,6 +28,7 @@ use std::io::BufWriter;
use std::io::Error;
use std::io::Write;
use std::io::{self};
+use std::path::Path;
use std::path::PathBuf;
use text_lines::TextLines;
use uuid::Uuid;
@@ -602,7 +604,8 @@ fn filter_coverages(
|| e.url.starts_with(npm_root_dir)
|| e.url.ends_with("__anonymous__")
|| e.url.ends_with("$deno$test.js")
- || e.url.ends_with(".snap");
+ || e.url.ends_with(".snap")
+ || is_supported_test_path(Path::new(e.url.as_str()));
let is_included = include.iter().any(|p| p.is_match(&e.url));
let is_excluded = exclude.iter().any(|p| p.is_match(&e.url));
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 977073ab7..853307374 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -1518,7 +1518,7 @@ async fn test_specifiers(
}
/// Checks if the path has a basename and extension Deno supports for tests.
-fn is_supported_test_path(path: &Path) -> bool {
+pub(crate) fn is_supported_test_path(path: &Path) -> bool {
if let Some(name) = path.file_stem() {
let basename = name.to_string_lossy();
(basename.ends_with("_test")