Skip to content
Merged
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
12 changes: 8 additions & 4 deletions internal/spectest/spectest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"testing"

"go.mongodb.org/mongo-driver/v2/internal/require"
Expand Down Expand Up @@ -42,10 +43,13 @@ func FindJSONFilesInDir(t *testing.T, dir string) []string {
// Path returns the absolute path to the given specifications repo file or
// subdirectory.
func Path(subdir string) string {
testPath, err := filepath.Abs("../../../testdata/specifications/source/")
if err != nil {
panic(err)
_, file, _, ok := runtime.Caller(0)
if !ok {
panic("unable to get current file path from call stack")
}

return filepath.Join(testPath, subdir)
// Get the repository root path from the current Go file path.
root := filepath.Dir(filepath.Dir(filepath.Dir(file)))

return filepath.Join(root, "testdata", "specifications", "source", subdir)
}
Loading