Helper to create a .dmap file in the test workspace
(t *testing.T, workspaceRoot, relPath string)
| 79 | |
| 80 | // Helper to create a .dmap file in the test workspace |
| 81 | func createTestDmapFile(t *testing.T, workspaceRoot, relPath string) { |
| 82 | t.Helper() |
| 83 | |
| 84 | dingoSrc := []byte("x := 10\n") |
| 85 | goSrc := []byte("x := 10\n") |
| 86 | |
| 87 | mappings := []sourcemap.LineMapping{ |
| 88 | {DingoLine: 1, GoLineStart: 1, GoLineEnd: 1, Kind: "identity"}, |
| 89 | } |
| 90 | |
| 91 | writer := dmap.NewWriter(dingoSrc, goSrc) |
| 92 | data, err := writer.Write(mappings, nil) |
| 93 | if err != nil { |
| 94 | t.Fatalf("Failed to create dmap data: %v", err) |
| 95 | } |
| 96 | |
| 97 | dmapPath := filepath.Join(workspaceRoot, ".dmap", relPath) |
| 98 | dmapDir := filepath.Dir(dmapPath) |
| 99 | |
| 100 | if err := os.MkdirAll(dmapDir, 0755); err != nil { |
| 101 | t.Fatalf("Failed to create dmap directory: %v", err) |
| 102 | } |
| 103 | |
| 104 | if err := os.WriteFile(dmapPath, data, 0644); err != nil { |
| 105 | t.Fatalf("Failed to write dmap file: %v", err) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestSourceMapCacheNew(t *testing.T) { |
| 110 | logger := &testLogger{} |
no test coverage detected