aboutsummaryrefslogtreecommitdiff
path: root/spdxconv_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'spdxconv_test.go')
-rw-r--r--spdxconv_test.go30
1 files changed, 26 insertions, 4 deletions
diff --git a/spdxconv_test.go b/spdxconv_test.go
index 77929e8..11a2a72 100644
--- a/spdxconv_test.go
+++ b/spdxconv_test.go
@@ -66,12 +66,22 @@ func TestInit(t *testing.T) {
MatchLicense: []*matchLicense{{
Pattern: `^(//+|#+|/\*+|<!--+)?\s*(.*)governed by a BSD-style(.*)$`,
LicenseIdentifier: `BSD-3-Clause`,
- DeleteLinePattern: []string{
+ DeleteLineBefore: []string{
+ `^(//+|#+|/\*+|<!--+)$`,
+ },
+ DeleteLineAfter: []string{
`^(//+|#+|/\*+|<!--+)?\s*license that can(.*)$`,
+ `^(//+|#+|\*+/|--+>)$`,
},
}},
MatchCopyright: []*matchCopyright{{
Pattern: `^(//+|#+|/\*+|<!--+)?\s*Copyright\s+(?<year>\d{4}),?\s+(?<author>.*)\s+<(?<contact>.*)>.*$`,
+ DeleteLineBefore: []string{
+ `^(//+|#+|/\*+|<!--+)$`,
+ },
+ DeleteLineAfter: []string{
+ `^(//+|#+|\*+/|--+>)$`,
+ },
}},
}
for _, mfc := range exp.MatchFileComment {
@@ -79,13 +89,25 @@ func TestInit(t *testing.T) {
}
for _, ml := range exp.MatchLicense {
ml.rePattern = regexp.MustCompile(ml.Pattern)
- for _, dlp := range ml.DeleteLinePattern {
+ for _, dlp := range ml.DeleteLineBefore {
+ re := regexp.MustCompile(dlp)
+ ml.reDeleteLineBefore = append(ml.reDeleteLineBefore, re)
+ }
+ for _, dlp := range ml.DeleteLineAfter {
re := regexp.MustCompile(dlp)
- ml.reDeleteLine = append(ml.reDeleteLine, re)
+ ml.reDeleteLineAfter = append(ml.reDeleteLineAfter, re)
}
}
for _, mc := range exp.MatchCopyright {
mc.rePattern = regexp.MustCompile(mc.Pattern)
+ for _, dlp := range mc.DeleteLineBefore {
+ re := regexp.MustCompile(dlp)
+ mc.reDeleteLineBefore = append(mc.reDeleteLineBefore, re)
+ }
+ for _, dlp := range mc.DeleteLineAfter {
+ re := regexp.MustCompile(dlp)
+ mc.reDeleteLineAfter = append(mc.reDeleteLineAfter, re)
+ }
}
test.Assert(t, `Init: loadConfig`, exp, conv.cfg)
}
@@ -111,7 +133,7 @@ func TestScan(t *testing.T) {
//spdxconv:header:path,license_id,idx_license_id,year,copyright_id,idx_copyright_id
//spdxconv:regular
test.go,match,1,2022,match,0,// ,
-test.html,match,2,2022,match,1,<!-- ," -->"
+test.html,match,4,2022,match,1,<!-- ," -->"
test.sh,match,1,2022,match,0,# ,
//spdxconv:binary
//spdxconv:unknown`