From f74d64b055933e93ed606d95c0d9aad98161ccb0 Mon Sep 17 00:00:00 2001 From: wuwen Date: Sat, 20 May 2023 18:36:48 +0800 Subject: [PATCH 1/2] fixed #36 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完善java测试文件过滤器,增加对测试包路径的判断 --- pkg/adapter/cocafile/file_filter.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/adapter/cocafile/file_filter.go b/pkg/adapter/cocafile/file_filter.go index 93f19073..421dc771 100644 --- a/pkg/adapter/cocafile/file_filter.go +++ b/pkg/adapter/cocafile/file_filter.go @@ -2,8 +2,16 @@ package cocafile import "strings" +var isJavaTestFile = func(path string) bool { + return strings.HasSuffix(path, "Test.java") || strings.HasSuffix(path, "Tests.java") +} + +var isJavaTestPackage = func(path string) bool { + return strings.Contains(path, "src/test/java/") +} + var JavaTestFileFilter = func(path string) bool { - return strings.Contains(path, "Test.java") || strings.Contains(path, "Tests.java") + return isJavaTestFile(path) || isJavaTestPackage(path) } var JavaCodeFileFilter = func(path string) bool { From 6975ae3b125c9a159f71d037ab9409ace96c5aad Mon Sep 17 00:00:00 2001 From: wuwen Date: Sat, 20 May 2023 19:14:33 +0800 Subject: [PATCH 2/2] Update file_filter.go fix filepath --- pkg/adapter/cocafile/file_filter.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/adapter/cocafile/file_filter.go b/pkg/adapter/cocafile/file_filter.go index 421dc771..7465cea7 100644 --- a/pkg/adapter/cocafile/file_filter.go +++ b/pkg/adapter/cocafile/file_filter.go @@ -1,12 +1,16 @@ package cocafile -import "strings" +import ( + "path/filepath" + "strings" +) var isJavaTestFile = func(path string) bool { return strings.HasSuffix(path, "Test.java") || strings.HasSuffix(path, "Tests.java") } var isJavaTestPackage = func(path string) bool { + path = filepath.ToSlash(path) return strings.Contains(path, "src/test/java/") }