diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-15 01:44:47 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-15 01:44:47 +0700 |
| commit | d0cb81287185db0c0fb088da5c35004af315cd42 (patch) | |
| tree | 581c0cee6648c82f8fe9674702fab89c6bdc2616 /report_test.go | |
| parent | 56f2fb3751f73ec7bc04f19a7bb36587340de298 (diff) | |
| download | spdxconv-d0cb81287185db0c0fb088da5c35004af315cd42.tar.xz | |
all: improve the scan by loading the existing report
In the second or next scan, load the existing spdxconv.report and check
if the file is already scanned before.
If the file is in group regular or binary, skip the scan; otherwise
re-scan it again.
Diffstat (limited to 'report_test.go')
| -rw-r--r-- | report_test.go | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/report_test.go b/report_test.go index abe7766..a042652 100644 --- a/report_test.go +++ b/report_test.go @@ -18,41 +18,49 @@ func TestLoadReport(t *testing.T) { t.Fatal(err) } exp := &report{ - listRegular: []*file{{ - path: `fileR1`, - licenseID: valDefault, - copyrightText: valDefault, - commentPrefix: `# `, - }, { - path: `file R2`, - licenseID: valExist, - idxLicenseID: 1, - copyrightYear: `2024`, - copyrightText: valExist, - idxCopyrightText: -1, - commentPrefix: `// `, - }, { - path: `fileR3`, - licenseID: valMatch, - idxLicenseID: -2, - copyrightYear: `2000-2026`, - copyrightText: valMatch, - idxCopyrightText: -3, - commentPrefix: `<!-- `, - commentSuffix: ` -->`, - }}, - listBinary: []*file{{ - path: `fileB1`, - licenseID: valDefault, - copyrightText: valDefault, - group: groupBinary, - }}, - listUnknown: []*file{{ - path: `fileU1`, - licenseID: valDefault, - copyrightText: valDefault, - group: groupUnknown, - }}, + listRegular: map[string]*file{ + `fileR1`: &file{ + path: `fileR1`, + licenseID: valDefault, + copyrightText: valDefault, + commentPrefix: `# `, + }, + `file R2`: &file{ + path: `file R2`, + licenseID: valExist, + idxLicenseID: 1, + copyrightYear: `2024`, + copyrightText: valExist, + idxCopyrightText: -1, + commentPrefix: `// `, + }, + `fileR3`: &file{ + path: `fileR3`, + licenseID: valMatch, + idxLicenseID: -2, + copyrightYear: `2000-2026`, + copyrightText: valMatch, + idxCopyrightText: -3, + commentPrefix: `<!-- `, + commentSuffix: ` -->`, + }, + }, + listBinary: map[string]*file{ + `fileB1`: &file{ + path: `fileB1`, + licenseID: valDefault, + copyrightText: valDefault, + group: groupBinary, + }, + }, + listUnknown: map[string]*file{ + `fileU1`: &file{ + path: `fileU1`, + licenseID: valDefault, + copyrightText: valDefault, + group: groupUnknown, + }, + }, } test.Assert(t, workDir, exp, got) } |
