From 5eed43069e5d41c1e0ac825496b4d076bc92d34b Mon Sep 17 00:00:00 2001 From: mappu Date: Fri, 7 Feb 2025 19:11:30 +1300 Subject: [PATCH] rcc/test: verify mtime changes --- cmd/miqt-rcc/integration_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/miqt-rcc/integration_test.go b/cmd/miqt-rcc/integration_test.go index fd495a08..48225883 100644 --- a/cmd/miqt-rcc/integration_test.go +++ b/cmd/miqt-rcc/integration_test.go @@ -118,6 +118,13 @@ replace github.com/mappu/miqt => ` + filepath.Clean(RccDir+`/../../`) + ` t.Run("Go generate", func(t *testing.T) { + // Check timestamp before generation + + fiBefore, err := os.Stat(filepath.Join(td, `resources.go`)) + if err != nil { + t.Fatal(err) + } + // Verify that `go generate` works regenCmd := exec.Command(`go`, `generate`) @@ -134,6 +141,17 @@ replace github.com/mappu/miqt => ` + filepath.Clean(RccDir+`/../../`) + ` t.Fatal(err) } + // Verify that the resources.go file was actually replaced + + fiAfter, err := os.Stat(filepath.Join(td, `resources.go`)) + if err != nil { + t.Fatal(err) + } + + if !fiAfter.ModTime().After(fiBefore.ModTime()) { + t.Errorf("expected mtime %v to be after original mtime %v", fiAfter.ModTime(), fiBefore.ModTime()) + } + // Verify the go:embed line accurately used a relative path if !strings.Contains(string(goResult), "//go:embed resources.rcc\n") {