Files
sdk/tests/standalone/script_snapshot_not_executed_test.dart
T
Ryan Macnak 913d828db0 [standalone] Restore --snapshot without --snapshot-kind generating a script snapshot.
Broken in d7845c6a6f

Issue #30790

Change-Id: Ifbe95a88e5b06d6d7fd1061bd26975262ac97515
Reviewed-on: https://dart-review.googlesource.com/6765
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2017-09-19 00:27:08 +00:00

52 lines
1.5 KiB
Dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "dart:io";
void main(List<String> args) {
if (args.contains("--child")) {
print("Hello, pre-scanned world!");
} else {
runSnapshot(generateSnapshot());
}
}
generateSnapshot() {
var tempDir = Directory.systemTemp.createTempSync("script-snapshot");
var snapshotPath = tempDir.uri.resolve("hello.snapshot").toFilePath();
var exec = Platform.resolvedExecutable;
var args = new List();
args.addAll(Platform.executableArguments);
args.add("--snapshot=$snapshotPath");
args.add(Platform.script.toFilePath());
args.add("--child");
var result = Process.runSync(exec, args);
if (result.exitCode != 0) {
throw "Bad exit code: ${result.exitCode}";
}
if (result.stdout.contains("Hello, pre-scanned world!")) {
print(result.stdout);
throw "Should not have run the script.";
}
return snapshotPath;
}
runSnapshot(var snapshotPath) {
var exec = Platform.resolvedExecutable;
var args = new List();
args.addAll(Platform.executableArguments);
args.add(snapshotPath);
args.add("--child");
var result = Process.runSync(exec, args);
if (result.exitCode != 0) {
throw "Bad exit code: ${result.exitCode}";
}
if (!result.stdout.contains("Hello, pre-scanned world!")) {
print(result.stdout);
throw "Failed to run the snapshot.";
}
}