Unverified Commit 7a487b2c authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Ensure we find dart.exe on local engines (#41514)

parent 5f9c262e
......@@ -158,6 +158,19 @@ abstract class Artifacts {
String getEngineType(TargetPlatform platform, [ BuildMode mode ]);
}
TargetPlatform get _currentHostPlatform {
if (platform.isMacOS) {
return TargetPlatform.darwin_x64;
}
if (platform.isLinux) {
return TargetPlatform.linux_x64;
}
if (platform.isWindows) {
return TargetPlatform.windows_x64;
}
throw UnimplementedError('Host OS not supported.');
}
/// Manages the engine artifacts downloaded to the local cache.
class CachedArtifacts extends Artifacts {
......@@ -337,19 +350,6 @@ class CachedArtifacts extends Artifacts {
assert(false, 'Invalid platform $platform.');
return null;
}
TargetPlatform get _currentHostPlatform {
if (platform.isMacOS) {
return TargetPlatform.darwin_x64;
}
if (platform.isLinux) {
return TargetPlatform.linux_x64;
}
if (platform.isWindows) {
return TargetPlatform.windows_x64;
}
throw UnimplementedError('Host OS not supported.');
}
}
/// Manages the artifacts of a locally built engine.
......@@ -362,7 +362,8 @@ class LocalEngineArtifacts extends Artifacts {
@override
String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) {
final String artifactFileName = _artifactToFileName(artifact);
platform ??= _currentHostPlatform;
final String artifactFileName = _artifactToFileName(artifact, platform);
switch (artifact) {
case Artifact.snapshotDart:
return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', artifactFileName);
......
......@@ -113,6 +113,20 @@ void main() {
FileSystem: () => memoryFileSystem,
Platform: () => FakePlatform(operatingSystem: 'linux'),
});
testUsingContext('Looks up dart.exe on windows platforms', () async {
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), contains('.exe'));
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
Platform: () => FakePlatform(operatingSystem: 'windows'),
});
testUsingContext('Looks up dart on linux platforms', () async {
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), isNot(contains('.exe')));
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
Platform: () => FakePlatform(operatingSystem: 'linux'),
});
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment