2026-08-07 21:28:24 +02:00
|
|
|
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
|
|
// Package format 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 ./format/
|
|
|
|
|
package format
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"sourcedock.dev/petrbalvin/gasm-devkit/parser"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TestRoundTripRealGoLibraries checks that formatting the production kernels
|
|
|
|
|
// still produces source that parses cleanly.
|
|
|
|
|
func TestRoundTripRealGoLibraries(t *testing.T) {
|
|
|
|
|
real, _ := filepath.Glob("../../go-libraries/go-*/*.s")
|
|
|
|
|
if len(real) == 0 {
|
|
|
|
|
t.Skip("go-libraries repository not present")
|
|
|
|
|
}
|
|
|
|
|
for _, path := range real {
|
|
|
|
|
src, err := os.ReadFile(path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
2026-08-29 17:12:53 +02:00
|
|
|
formatted := Source(string(src))
|
2026-08-07 21:28:24 +02:00
|
|
|
if _, errs := parser.Parse(path, formatted); len(errs) > 0 {
|
|
|
|
|
t.Errorf("formatted %s no longer parses: %v", path, errs)
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(formatted) == "" {
|
|
|
|
|
t.Errorf("formatted %s is empty", path)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|