Skip to content

Commit 80f8671

Browse files
authored
File paths in TestContext are relative, not absolute (#1843)
1 parent 6dedcd5 commit 80f8671

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

dwds/test/dart_uri_file_uri_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ final context = TestContext(
2323
final dwdsDir = Directory.current.absolute.path;
2424

2525
/// The directory for the general _test package.
26-
final testDir = p.join(p.dirname(dwdsDir), 'fixtures', '_test');
26+
final testDir = p.normalize(p.absolute(p.relative(
27+
p.join('..', 'fixtures', '_test'),
28+
from: p.current,
29+
)));
2730

2831
/// The directory for the _testPackage package (contained within dwds), which
2932
/// imports _test.

dwds/test/fixtures/context.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ class TestContext {
121121
this.path = 'hello_world/index.html',
122122
this.pathToServe = 'example',
123123
}) {
124-
final packageName = nullSafety == NullSafety.sound ? '_testSound' : '_test';
125-
final relativeDirectory = p.join('..', 'fixtures', packageName);
124+
final defaultPackage =
125+
nullSafety == NullSafety.sound ? '_testSound' : '_test';
126+
final defaultDirectory = p.join('..', 'fixtures', defaultPackage);
127+
final defaultEntry = p.join('..', 'fixtures', defaultPackage, 'example',
128+
'append_body', 'main.dart');
126129

127-
final relativeEntry = p.join(
128-
'..', 'fixtures', packageName, 'example', 'append_body', 'main.dart');
129-
130-
workingDirectory = p.normalize(p
131-
.absolute(directory ?? p.relative(relativeDirectory, from: p.current)));
130+
workingDirectory = p.normalize(
131+
p.absolute(p.relative(directory ?? defaultDirectory, from: p.current)));
132132

133133
DartUri.currentDirectory = workingDirectory;
134134

@@ -138,7 +138,7 @@ class TestContext {
138138
p.toUri(p.join(workingDirectory, '.dart_tool/package_config.json'));
139139

140140
final entryFilePath = p.normalize(
141-
p.absolute(entry ?? p.relative(relativeEntry, from: p.current)));
141+
p.absolute(p.relative(entry ?? defaultEntry, from: p.current)));
142142

143143
_logger.info('Serving: $pathToServe/$path');
144144
_logger.info('Project: $_projectDirectory');

0 commit comments

Comments
 (0)