diff options
Diffstat (limited to 'spdxconv_test.go')
| -rw-r--r-- | spdxconv_test.go | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/spdxconv_test.go b/spdxconv_test.go index 1496e14..52bd114 100644 --- a/spdxconv_test.go +++ b/spdxconv_test.go @@ -37,38 +37,54 @@ func TestInit(t *testing.T) { exp := config{ MaxLineMatch: 10, MatchFileComment: []*matchFileComment{{ - Pattern: `^.*\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx|jsonc|kt|kts|php|rs|sass|scss|swift|ts|tsx)$`, - Prefix: `//`, - }, { - Pattern: `^(.*/)?go.mod$`, - Prefix: `//`, - }, { - Pattern: `^.*\.(aff|bash|csh|dockerfile|env|gitignore|hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|yaml|yml|zsh)$`, - Prefix: `#`, + Pattern: []string{ + `^.*\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx)$`, + `^.*\.(jsonc|kt|kts|php|rs|sass|scss|swift|ts|tsx)$`, + `^(.*/)?(go.mod|go.work)$`, + }, + Prefix: `//`, }, { - Pattern: `^(.*/)?[Mm]akefile$`, - Prefix: `#`, + Pattern: []string{ + `^.*\.(aff|aww|bash|csh|d2|dockerfile|env|gitignore|gitmodules)$`, + `^.*\.(hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|toml|yaml|yml|zsh)$`, + `^(.*/)?([Dd]ockerfile|[Mm]akefile|robots.txt)$`, + `^.*\.(automount|device|mount|path|scope|service|slice|socket|swap|target|timer)$`, + }, + Prefix: `#`, }, { - Pattern: `^.*\.(css)$`, + Pattern: []string{`^.*\.(css)$`}, Prefix: `/*`, Suffix: `*/`, }, { - Pattern: `^.*\.(fxml|htm|html|html5|kml|markdown|md|xml)$`, - Prefix: `<!--`, - Suffix: `-->`, - }, { - Pattern: `^.*\.(lua|sql)$`, - Prefix: `--`, + Pattern: []string{ + `^.*\.(fxml|gohtml|htm|html|html5|kml|markdown|md|xml)$`, + }, + Prefix: `<!--`, + Suffix: `-->`, }, { - Pattern: `^.*\.(rst)$`, - Prefix: `..`, + Pattern: []string{ + `^.*\.(lua|sql)$`, + }, + Prefix: `--`, }, { - Pattern: `^.*\.(tex)$`, - Prefix: `%`, + Pattern: []string{ + `^.*\.(rst)$`, + }, + Prefix: `..`, }, { - Pattern: `^.*\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$`, + Pattern: []string{ + `^.*\.(tex)$`, + }, + Prefix: `%`, }, { - Pattern: `^(.*/)?go.sum$`, + Pattern: []string{ + `^.*\.(apk|app|bz2|exe|gz|tar|tgz|zip)$`, + `^.*\.(csv|doc|docx|json|pdf|ppt|pptx|xls|xlsx)$`, + `^.*\.(bmp|gif|ico|jpeg|jpg|png|svg|svgz|webp)$`, + `^.*\.(3gp|avi|flv|mkv|mp3|mp4|mpeg|mpg|mpg4)$`, + `^.*\.(acc|ogg|mp3)$`, + `^(.*/)?(go.sum|go.work.sum)$`, + }, }}, MatchLicense: []*matchLicense{{ Pattern: `^(//+|#+|/\*+|<!--+|--+)?\s*(.*)governed by a BSD-style(.*)$`, @@ -92,7 +108,10 @@ func TestInit(t *testing.T) { }}, } for _, mfc := range exp.MatchFileComment { - mfc.rePattern = regexp.MustCompile(mfc.Pattern) + for _, pattern := range mfc.Pattern { + re := regexp.MustCompile(pattern) + mfc.rePattern = append(mfc.rePattern, re) + } } for _, ml := range exp.MatchLicense { ml.rePattern = regexp.MustCompile(ml.Pattern) |
