Skip to content

Commit d05a122

Browse files
Andreas Humenbergerbauersimon
authored andcommitted
fix, Resolve symlinks in temporary repository paths to have consistent paths
It seems that the temporary root directory /var points to /private/var on macOS. And some usages of the path resolve symlinks (e.g. "git init") and other do not, yielding a mismatch in file paths.
1 parent b8442e7 commit d05a122

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

evaluate/task/repository.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func TemporaryRepository(logger *log.Logger, testDataPath string, repositoryPath
155155
if err != nil {
156156
return nil, cleanup, pkgerrors.WithStack(err)
157157
}
158+
temporaryPath, err = filepath.EvalSymlinks(temporaryPath)
159+
if err != nil {
160+
return nil, cleanup, pkgerrors.WithStack(err)
161+
}
158162

159163
cleanup = func() {
160164
if e := os.RemoveAll(temporaryPath); e != nil {

evaluate/task/repository_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func TestTemporaryRepository(t *testing.T) {
4141
actualTemporaryRepository, cleanup, actualErr := TemporaryRepository(logger, tc.TestDataPath, tc.RepositoryPath)
4242
defer cleanup()
4343

44-
assert.Regexp(t, regexp.QuoteMeta(filepath.Clean(os.TempDir())+string(os.PathSeparator))+tc.ExpectedTempPathRegex, actualTemporaryRepository, actualTemporaryRepository)
44+
temporaryDirectory, err := filepath.EvalSymlinks(os.TempDir())
45+
require.NoError(t, err)
46+
assert.Regexp(t, regexp.QuoteMeta(temporaryDirectory+string(os.PathSeparator))+tc.ExpectedTempPathRegex, actualTemporaryRepository, actualTemporaryRepository)
4547
assert.Equal(t, tc.ExpectedErr, actualErr)
4648

4749
if tc.ValidateAfter != nil {

language/rust/language.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"strings"
1414

1515
pkgerrors "github.com/pkg/errors"
16-
"github.com/zimmski/osutil"
1716
"github.com/zimmski/osutil/bytesutil"
1817

1918
"github.com/symflower/eval-dev-quality/language"
@@ -165,13 +164,6 @@ func (l *Language) ExecuteTests(logger *log.Logger, repositoryPath string) (test
165164
if err != nil {
166165
return testResult, problems, pkgerrors.WithMessage(pkgerrors.WithStack(err), commandOutput)
167166
}
168-
for _, block := range coverageData {
169-
// HACK The coverage should only contain relative paths but contains a weird build folder on macOS.
170-
if index := strings.Index(block.FilePath, "src"); index != -1 && osutil.IsDarwin() && filepath.IsAbs(block.FilePath) {
171-
block.FilePath = block.FilePath[index:]
172-
}
173-
}
174-
175167
for _, block := range coverageData {
176168
if lineStart, ok := testStartLinePerFile[block.FilePath]; ok && block.LineEnd < lineStart && block.Count > 0 {
177169
testResult.Coverage++

0 commit comments

Comments
 (0)