aboutsummaryrefslogtreecommitdiff
path: root/spdxconv_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-12 23:01:35 +0700
committerShulhan <ms@kilabit.info>2026-01-12 23:01:35 +0700
commite16e2a4ec74443aa8f4c21a73ee837cb72ed46fb (patch)
tree8458e4f7bc3803310f1e4071a28a70bb8f0fd939 /spdxconv_test.go
parent9817757f8dca159aa261315a91fceff1d9a13566 (diff)
downloadspdxconv-e16e2a4ec74443aa8f4c21a73ee837cb72ed46fb.tar.xz
all: fix default regex match license and copyright to ignore comment
Instead of assuming that the comment prefix and space always exists "^(//)\s+..." change it to be optional, so it will works on the multi-line comment. For example, comment and old headers in html, <-- Copyright ... --> there is no comment prefix and space.
Diffstat (limited to 'spdxconv_test.go')
-rw-r--r--spdxconv_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/spdxconv_test.go b/spdxconv_test.go
index 194276e..77929e8 100644
--- a/spdxconv_test.go
+++ b/spdxconv_test.go
@@ -64,14 +64,14 @@ func TestInit(t *testing.T) {
Pattern: `^.*\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$`,
}},
MatchLicense: []*matchLicense{{
- Pattern: `^(//+|#+)\s+(.*)governed by a BSD-style(.*)$`,
+ Pattern: `^(//+|#+|/\*+|<!--+)?\s*(.*)governed by a BSD-style(.*)$`,
LicenseIdentifier: `BSD-3-Clause`,
DeleteLinePattern: []string{
- `^(//+|#+)\s+license that(.*)$`,
+ `^(//+|#+|/\*+|<!--+)?\s*license that can(.*)$`,
},
}},
MatchCopyright: []*matchCopyright{{
- Pattern: `^(//+|#+)\s+Copyright\s+(?<year>\d{4}),?\s+(?<author>.*)\s+<*(?<contact>.*)>.*$`,
+ Pattern: `^(//+|#+|/\*+|<!--+)?\s*Copyright\s+(?<year>\d{4}),?\s+(?<author>.*)\s+<(?<contact>.*)>.*$`,
}},
}
for _, mfc := range exp.MatchFileComment {
@@ -110,9 +110,9 @@ func TestScan(t *testing.T) {
//spdxconv:version:v1
//spdxconv:header:path,license_id,idx_license_id,year,copyright_id,idx_copyright_id
//spdxconv:regular
-test.go,match,1,unknown,match,0,// ,
-test.html,default,0,unknown,default,0,<!-- ," -->"
-test.sh,match,1,unknown,match,0,# ,
+test.go,match,1,2022,match,0,// ,
+test.html,match,2,2022,match,1,<!-- ," -->"
+test.sh,match,1,2022,match,0,# ,
//spdxconv:binary
//spdxconv:unknown`