45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|||
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
|
|
||
|
|
//go:build integration
|
||
|
|
|
||
|
|
// Package lint integration tests against the production go-libraries kernels.
|
||
|
|
// Excluded from the default test run so coverage is identical locally and in CI.
|
||
|
|
// Run explicitly with: go test -tags=integration ./lint/
|
||
|
|
package lint
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"sourcedock.dev/petrbalvin/gasm-devkit/arch"
|
||
|
|
"sourcedock.dev/petrbalvin/gasm-devkit/parser"
|
||
|
|
)
|
||
|
|
|
||
|
|
// TestRealGoLibrariesHasNoErrors asserts that the production go-flac kernels
|
||
|
|
// lint free of errors.
|
||
|
|
func TestRealGoLibrariesHasNoErrors(t *testing.T) {
|
||
|
|
matches, _ := filepath.Glob("../../go-libraries/go-*/*.s")
|
||
|
|
if len(matches) == 0 {
|
||
|
|
t.Skip("go-libraries repository not present")
|
||
|
|
}
|
||
|
|
for _, path := range matches {
|
||
|
|
src, err := os.ReadFile(path)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
f, errs := parser.Parse(path, string(src))
|
||
|
|
if len(errs) > 0 {
|
||
|
|
t.Fatalf("parse %s: %v", path, errs)
|
||
|
|
}
|
||
|
|
a := arch.FromFilename(path)
|
||
|
|
diags := File(f, Config{Arch: a})
|
||
|
|
for _, d := range diags {
|
||
|
|
if d.Severity == Error {
|
||
|
|
t.Errorf("%s: %s %s: %s", filepath.Base(path), d.Pos, d.Code, d.Message)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|