Skip to content

Commit ff64ab8

Browse files
committed
add path finder
1 parent d8929ee commit ff64ab8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

enginetest/queries/binlog_queries.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ package queries
1616

1717
import (
1818
"os"
19+
"path/filepath"
20+
"runtime"
1921
"strings"
2022

2123
"github.com/dolthub/go-mysql-server/sql"
2224
"github.com/dolthub/go-mysql-server/sql/types"
2325
)
2426

2527
var (
26-
binlogInsertStmts = readBinlogTestFile("./testdata/binlog_insert.txt")
27-
binlogUpdateStmts = readBinlogTestFile("./testdata/binlog_update.txt")
28-
binlogDeleteStmts = readBinlogTestFile("./testdata/binlog_delete.txt")
29-
binlogFormatDescStmts = readBinlogTestFile("./testdata/binlog_format_desc.txt")
30-
binlogTransactionMultiOps = readBinlogTestFile("./testdata/binlog_transaction_multi_ops.txt")
31-
binlogNoFormatDescStmts = readBinlogTestFile("./testdata/binlog_no_format_desc.txt")
28+
binlogInsertStmts = parseBinlogTestFile("binlog_insert.txt")
29+
binlogUpdateStmts = parseBinlogTestFile("binlog_update.txt")
30+
binlogDeleteStmts = parseBinlogTestFile("binlog_delete.txt")
31+
binlogFormatDescStmts = parseBinlogTestFile("binlog_format_desc.txt")
32+
binlogTransactionMultiOps = parseBinlogTestFile("binlog_transaction_multi_ops.txt")
33+
binlogNoFormatDescStmts = parseBinlogTestFile("binlog_no_format_desc.txt")
3234
)
3335

3436
// BinlogScripts contains test cases for the BINLOG statement. To add tests: add a @test to binlog_maker.bats, generate
@@ -170,10 +172,15 @@ var BinlogScripts = []ScriptTest{
170172
},
171173
}
172174

173-
// readBinlogTestFile reads BINLOG statements from a testdata file. The file is pre-filtered by binlog_maker.bats to
175+
// parseBinlogTestFile parses BINLOG statements from a testdata file. The file is pre-filtered by binlog_maker.bats to
174176
// contain only BINLOG statements.
175-
func readBinlogTestFile(path string) []string {
176-
data, err := os.ReadFile(path)
177+
func parseBinlogTestFile(filename string) []string {
178+
_, sourceFile, _, _ := runtime.Caller(0)
179+
sourceDir := filepath.Dir(sourceFile)
180+
181+
testdataPath := filepath.Join(sourceDir, "..", "testdata", filename)
182+
183+
data, err := os.ReadFile(testdataPath)
177184
if err != nil {
178185
return nil
179186
}

0 commit comments

Comments
 (0)