mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[macros] Tests find SDK out instead of hard coding it.
R=whesse@google.com Change-Id: I0ecdf8ef53e79234f8d2957ac680e8ec103e496a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356042 Auto-Submit: Morgan :) <davidmorgan@google.com> Reviewed-by: William Hesse <whesse@google.com> Commit-Queue: Morgan :) <davidmorgan@google.com>
This commit is contained in:
parent
7e2679df05
commit
ffe61b76d8
|
@ -8,8 +8,7 @@ void main() {
|
|||
testMacroBuild([
|
||||
r'$DART pub get',
|
||||
r'$DART '
|
||||
// TODO(davidmorgan): find this programmatically.
|
||||
r'$DART_SDK/out/DebugX64/gen/dartanalyzer.dart.snapshot '
|
||||
r'$DART_SDK_OUT/gen/dartanalyzer.dart.snapshot '
|
||||
'-Dtest_runner.configuration=analyzer-asserts-linux '
|
||||
'--enable-experiment=macros '
|
||||
'--ignore-unrecognized-flags '
|
||||
|
|
|
@ -12,8 +12,7 @@ void main() {
|
|||
'--verify '
|
||||
'--skip-platform-verification -o out.dill '
|
||||
'--platform '
|
||||
// TODO(davidmorgan): find this programmatically.
|
||||
r'$DART_SDK/out/DebugX64/vm_platform_strong.dill '
|
||||
r'$DART_SDK_OUT/vm_platform_strong.dill '
|
||||
'-Dtest_runner.configuration=cfe-strong-linux '
|
||||
'--enable-experiment=macros '
|
||||
'--nnbd-strong '
|
||||
|
|
|
@ -10,6 +10,21 @@ import 'package:expect/expect.dart';
|
|||
import 'package:path/path.dart' as p;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
final dartSdkOutDirectory = _findSdkOutDirectory();
|
||||
|
||||
String _findSdkOutDirectory() {
|
||||
var dartSdkOutDirectory = File(Platform.resolvedExecutable).parent;
|
||||
if (!Directory.fromUri(dartSdkOutDirectory.uri.resolve('gen')).existsSync()) {
|
||||
// Not next to `dart`, try two levels up for `dart-sdk/bin` suffix.
|
||||
dartSdkOutDirectory = dartSdkOutDirectory.parent.parent;
|
||||
}
|
||||
if (!Directory.fromUri(dartSdkOutDirectory.uri.resolve('gen')).existsSync()) {
|
||||
fail("Can't find SDK 'gen' directory from ${Platform.resolvedExecutable}, "
|
||||
'please run from an SDK build out.');
|
||||
}
|
||||
return dartSdkOutDirectory.path;
|
||||
}
|
||||
|
||||
/// Tests a macro build specified by [commands].
|
||||
///
|
||||
/// The commands are launched with current directory set to a temp folder with
|
||||
|
@ -30,7 +45,7 @@ Future<void> testMacroBuild(List<String> commands) async {
|
|||
var workingDirectory = '${temp.path}/package_under_test';
|
||||
await _copyPath(sourceDirectory, workingDirectory);
|
||||
|
||||
var dartSdkPath = Directory.current.path;
|
||||
final dartSdkPath = Directory.current.path;
|
||||
final dartPath = Platform.resolvedExecutable;
|
||||
|
||||
// TODO(davidmorgan): run on more platforms.
|
||||
|
@ -51,6 +66,10 @@ runner to ensure they are built and not stale:
|
|||
var failed = false;
|
||||
var timedOut = false;
|
||||
for (var command in commands) {
|
||||
if (command.contains(r'$DART_SDK_OUT')) {
|
||||
// Only search for SDK out directory if it's needed for this test case.
|
||||
command = command.replaceAll(r'$DART_SDK_OUT', dartSdkOutDirectory);
|
||||
}
|
||||
final commandParts = command
|
||||
.replaceAll(r'$DART_SDK', dartSdkPath)
|
||||
.replaceAll(r'$DART', dartPath)
|
||||
|
|
Loading…
Reference in a new issue