Skip to content

Commit 924e66d

Browse files
committed
Fix tests: always relativize path
1 parent d7dd989 commit 924e66d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/util/SourceFile.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,8 @@ object SourceFile {
201201
val jpath = file.jpath
202202
if jpath eq null then
203203
file.path // repl and other custom tests use abstract files with no path
204-
else if jpath.isAbsolute then
205-
sourcerootPath.relativize(jpath.normalize).toString
206204
else
207-
jpath.normalize.toString
205+
sourcerootPath.relativize(jpath.toAbsolutePath.normalize).toString
208206
}
209207
}
210208

project/scripts/cmdTests

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ echo "testing that paths SourceFile annotations are relativized"
3838
clear_out "$OUT"
3939
"$SBT" "scalac -d $OUT/out.jar -sourceroot tests/pos $(pwd)/tests/pos/i10430/lib.scala $(pwd)/tests/pos/i10430/app.scala"
4040
"$SBT" "scalac -decompile -color:never $OUT/out.jar" > "$tmp"
41-
grep -qe ": lib.scala" "$tmp"
42-
grep -qe ": app.scala" "$tmp"
43-
grep -qe "[lib.scala]" "$tmp"
44-
grep -qe "[app.scala]" "$tmp"
41+
grep -qe ": i10430/lib.scala" "$tmp"
42+
grep -qe ": i10430/app.scala" "$tmp"
43+
grep -qe "[i10430/lib.scala]" "$tmp"
44+
grep -qe "[i10430/app.scala]" "$tmp"
4545
grep -v "tests/pos/i10430/lib.scala" "$tmp"
4646
grep -v "tests/pos/i10430/app.scala" "$tmp"
4747

0 commit comments

Comments
 (0)