fix(ax): enforce SPDX headers in references
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
3d7ec7efce
commit
398f59f461
5 changed files with 58 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
// Sandboxed local filesystem I/O for the Core framework.
|
||||
package core
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
// Structured logging for the Core framework.
|
||||
//
|
||||
// core.SetLevel(core.LevelDebug)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
package lib
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
|
|
@ -296,3 +297,52 @@ func TestLib_ExtractWorkspace_Good_AXConventions(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLib_ReferenceFiles_Good_SPDXHeaders(t *testing.T) {
|
||||
_, file, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
t.Fatal("runtime.Caller(0) failed")
|
||||
}
|
||||
|
||||
repoRoot := core.PathDir(core.PathDir(core.PathDir(file)))
|
||||
refDir := core.JoinPath(repoRoot, ".core", "reference")
|
||||
goFiles := core.PathGlob(core.JoinPath(refDir, "*.go"))
|
||||
if len(goFiles) == 0 {
|
||||
t.Fatalf("no .go files found in %s", refDir)
|
||||
}
|
||||
|
||||
for _, path := range goFiles {
|
||||
assertSPDXHeader(t, path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLib_ExtractWorkspace_Good_ReferenceHeaders(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
data := &WorkspaceData{Repo: "test-repo", Task: "carry SPDX headers into workspace references"}
|
||||
|
||||
if err := ExtractWorkspace("default", dir, data); err != nil {
|
||||
t.Fatalf("ExtractWorkspace failed: %v", err)
|
||||
}
|
||||
|
||||
refDir := core.JoinPath(dir, ".core", "reference")
|
||||
goFiles := core.PathGlob(core.JoinPath(refDir, "*.go"))
|
||||
if len(goFiles) == 0 {
|
||||
t.Fatalf("no extracted .go files found in %s", refDir)
|
||||
}
|
||||
|
||||
for _, path := range goFiles {
|
||||
assertSPDXHeader(t, path)
|
||||
}
|
||||
}
|
||||
|
||||
func assertSPDXHeader(t *testing.T, path string) {
|
||||
t.Helper()
|
||||
|
||||
r := testFs.Read(path)
|
||||
if !r.OK {
|
||||
t.Fatalf("failed to read %s", path)
|
||||
}
|
||||
if !core.HasPrefix(r.Value.(string), "// SPDX-License-Identifier: EUPL-1.2") {
|
||||
t.Fatalf("%s missing SPDX header", path)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
// Sandboxed local filesystem I/O for the Core framework.
|
||||
package core
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
// Structured logging for the Core framework.
|
||||
//
|
||||
// core.SetLevel(core.LevelDebug)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue