Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion interp/interp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func runTest(t *testing.T, pathPrefix string) {
// Read the input IR.
ctx := llvm.NewContext()
defer ctx.Dispose()
ensureTestCacheFreshness(t, pathPrefix+".ll")
buf, err := llvm.NewMemoryBufferFromFile(pathPrefix + ".ll")
os.Stat(pathPrefix + ".ll") // make sure this file is tracked by `go test` caching
if err != nil {
t.Fatalf("could not read file %s: %v", pathPrefix+".ll", err)
}
Expand Down Expand Up @@ -153,3 +153,12 @@ func filterIrrelevantIRLines(lines []string) []string {
}
return out
}

// ensureTestCacheFreshness registers path as an input of the running test.
// see https://github.com/tinygo-org/tinygo/issues/5780.
func ensureTestCacheFreshness(t *testing.T, path string) {
t.Helper()
if _, err := os.Stat(path); err != nil {
t.Fatalf("could not stat test fixture %s: %v", path, err)
}
}
3 changes: 1 addition & 2 deletions transform/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package transform_test

import (
"errors"
"os"
"testing"

"github.com/tinygo-org/tinygo/transform"
Expand Down Expand Up @@ -37,8 +36,8 @@ func TestGCStackSlotCounts(t *testing.T) {

ctx := llvm.NewContext()
defer ctx.Dispose()
ensureTestCacheFreshness(t, "testdata/gc-slotcounts.ll")
buf, err := llvm.NewMemoryBufferFromFile("testdata/gc-slotcounts.ll")
os.Stat("testdata/gc-slotcounts.ll") // make sure `go test` caching tracks this file
if err != nil {
t.Fatalf("could not read file: %v", err)
}
Expand Down
11 changes: 11 additions & 0 deletions transform/optimizer_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transform

import (
"os"
"testing"

"tinygo.org/x/go-llvm"
Expand All @@ -9,6 +10,7 @@ import (
func TestBlockGlobalAllocPromotionUses(t *testing.T) {
ctx := llvm.NewContext()
defer ctx.Dispose()
ensureTestCacheFreshness(t, "testdata/optimizer-alloc-uses.ll")
buf, err := llvm.NewMemoryBufferFromFile("testdata/optimizer-alloc-uses.ll")
if err != nil {
t.Fatal(err)
Expand All @@ -31,3 +33,12 @@ func TestBlockGlobalAllocPromotionUses(t *testing.T) {
t.Fatalf("got %d marker uses, want 1", len(uses))
}
}

// ensureTestCacheFreshness registers path as an input of the running test.
// see https://github.com/tinygo-org/tinygo/issues/5780.
func ensureTestCacheFreshness(t *testing.T, path string) {
t.Helper()
if _, err := os.Stat(path); err != nil {
t.Fatalf("could not stat test fixture %s: %v", path, err)
}
}
11 changes: 10 additions & 1 deletion transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func testTransform(t *testing.T, pathPrefix string, transform func(mod llvm.Modu
// Read the input IR.
ctx := llvm.NewContext()
defer ctx.Dispose()
ensureTestCacheFreshness(t, pathPrefix+".ll")
buf, err := llvm.NewMemoryBufferFromFile(pathPrefix + ".ll")
os.Stat(pathPrefix + ".ll") // make sure this file is tracked by `go test` caching
if err != nil {
t.Fatalf("could not read file %s: %v", pathPrefix+".ll", err)
}
Expand Down Expand Up @@ -265,3 +265,12 @@ func getPosition(val llvm.Value) token.Position {
return token.Position{}
}
}

// ensureTestCacheFreshness registers path as an input of the running test.
// see https://github.com/tinygo-org/tinygo/issues/5780.
func ensureTestCacheFreshness(t *testing.T, path string) {
t.Helper()
if _, err := os.Stat(path); err != nil {
t.Fatalf("could not stat test fixture %s: %v", path, err)
}
}
Loading