Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Dart VM tests with snapshot #73

Merged
merged 2 commits into from Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -10,10 +10,12 @@ cache:

before_script:
- if-node() { if [ ! -z "$NODE_VERSION" ]; then "$@"; fi }
- if-dart() { if [ -z "$NODE_VERSION" ]; then "$@"; fi }
- if-node . "$HOME/.nvm/nvm.sh"
- if-node nvm install "$NODE_VERSION"
- if-node nvm use "$NODE_VERSION"
- if-node pub run grinder js
- if-dart pub run grinder app-snapshot

jobs:
include:
Expand Down Expand Up @@ -89,7 +91,7 @@ jobs:
if: *deploy-if
env:
# PUB_CREDENTIALS="..."
- secure: "QCNhSiluq2TPf20ekwWlf+TkyzwnGwqS3pU+3XogRlP6ffRcG98zL9pn7cp8xmaM50x9PY6nk0t+oxkiOFw7sKhECfIRv0Z+P4cURhTUJ25+FqLPupCSqehoF93Bx8fXQR+2KCEP+cEeu2dcDU0hAZnzSWliRm/X/6Hfy+2M5eVc4x0+YC/gDjdbNbgH5P29qhRSB7klB8FtKDQdmQro0l1jSe69RGUmaeFSG7ryn+OlCJNMZqwZBd2Yb7pShiegU1ks/fIrC+pf/Yx2/VUscyLGwWqNxl6xXeZko3bNNCNPhPNIjArZJTNKMHvuIvKEvjfrUIr6TwGsw9vJmGjAbSiZzeXfeJ5zBp9ZaL1i8g5WwvVoQcbFgTn/vCisLZ97NP+0ipKr1VXxDfJ+MThaFsbOnl4wcC9XrrqQERWjH4lNGdfywvjql+d1M48veGqeYYY64UhiGDS+98t6GG+Q+ScQh5LDbn/uaQhi6DUCCqzaphdr78ylVrt7RzIdauOcu/CY3q22Kfm+wOZd+4S3Abk3L7P3eWl60sm/yUCx6yTA1rZPBylL5+R3cQS+9Lp9lll03Xcuf/L+MD7pVsN/RB5L52zn51oxtuVvjU01R0JZ8vWSgZ7CMs1BD7DXCjz9deGvBCHJR5aFelygt9ZSuIaM2xpZ2uSFscUnf6qjSh4="
- secure: "QCNhSiluq2TPf20ekwWlf+TkyzwnGwqS3pU+3XogRlP6ffRcG98zL9pn7cp8xmaM50x9PY6nk0t+oxkiOFw7sKhECfIRv0Z+P4cURhTUJ25+FqLPupCSqehoF93Bx8fXQR+2KCEP+cEeu2dcDU0hAZnzSWliRm/X/6Hfy+2M5eVc4x0+YC/gDjdbNbgH5P29qhRSB7klB8FtKDQdmQro0l1jSe69RGUmaeFSG7ryn+OlCJNMZqwZBd2Yb7pShiegU1ks/fIrC+pf/Yx2/VUscyLGwWqNxl6xXeZko3bNNCNPhPNIjArZJTNKMHvuIvKEvjfrUIr6TwGsw9vJmGjAbSiZzeXfeJ5zBp9ZaL1i8g5WwvVoQcbFgTn/vCisLZ97NP+0ipKr1VXxDfJ+MThaFsbOnl4wcC9XrrqQERWjH4lNGdfywvjql+d1M48veGqeYYY64UhiGDS+98t6GG+Q+ScQh5LDbn/uaQhi6DUCCqzaphdr78ylVrt7RzIdauOcu/CY3q22Kfm+wOZd+4S3Abk3L7P3eWl60sm/yUCx6yTA1rZPBylL5+R3cQS+9Lp9lll03Xcuf/L+MD7pVsN/RB5L52zn51oxtuVvjU01R0JZ8vWSgZ7CMs1BD7DXCjz9deGvBCHJR5aFelygt9ZSuIaM2xpZ2uSFscUnf6qjSh4="
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I ignore whitespace with git diff -w, this goes away, so I think my editor automatically converted tabs to spaces.

script: skip
deploy:
provider: script
Expand Down
27 changes: 23 additions & 4 deletions test/migrator_utils.dart
Expand Up @@ -18,16 +18,26 @@ import 'package:test_process/test_process.dart';
/// If [node] is `true`, runs the Node.js version of the executable. Otherwise,
/// runs the Dart VM version.
void testMigrator(String migrator, {bool node: false}) {
var useSnapshot = true;
if (node) {
_ensureUpToDate("build/sass_migrator.dart.js", "pub run grinder js");
} else {
try {
_ensureUpToDate("build/sass_migrator.dart.app.snapshot",
'pub run grinder app-snapshot');
} catch (_) {
useSnapshot = false;
}
}

var migrationTests = Directory("test/migrators/$migrator");
group(migrator, () {
for (var file in migrationTests.listSync().whereType<File>()) {
if (file.path.endsWith(".hrx")) {
test(p.basenameWithoutExtension(file.path),
() => _testHrx(file, migrator, node: node));
test(
p.basenameWithoutExtension(file.path),
() =>
_testHrx(file, migrator, node: node, useSnapshot: useSnapshot));
}
}
});
Expand Down Expand Up @@ -77,14 +87,23 @@ void _ensureUpToDate(String path, String commandToRun) {
///
/// If [node] is `true`, runs the Node.js version of the executable. Otherwise,
/// runs the Dart VM version.
Future<void> _testHrx(File hrxFile, String migrator, {bool node: false}) async {
///
/// If [useSnapshot] is `true` and using the Dart VM, an app snapshot will be
/// used instead of running directly from source.
Future<void> _testHrx(File hrxFile, String migrator,
{bool node: false, bool useSnapshot: false}) async {
var files = _HrxTestFiles(hrxFile.readAsStringSync());
await files.unpack();

var executable = node ? "node" : Platform.executable;
var executableArgs = node
? [p.absolute("build/sass_migrator.dart.js")]
: ["--enable-asserts", p.absolute("bin/sass_migrator.dart")];
: [
"--enable-asserts",
p.absolute(useSnapshot
? "build/sass_migrator.dart.app.snapshot"
: "bin/sass_migrator.dart")
];

var process = await TestProcess.start(
executable,
Expand Down