From 830bb3aab2672acdd596361d8ba0cd1af98babef Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Tue, 8 Sep 2020 09:23:46 -0700 Subject: [PATCH] Move Node tests on Windows to Travis (#1063) * Move Node tests on Windows to Travis Appveyor is flaky and can't be restarted by all team members, so moving everything to Travis is preferable if we can get it to work. * Actually use latest stable Node This should also workaround the issue with lts/* not working on Windows. * Use npm.cmd instead of raw npm on Windows * Use p.prettyUri() for Node API tests Co-authored-by: Natalie Weizenbaum --- .travis.yml | 8 +++----- appveyor.yml | 21 --------------------- test/node_api_test.dart | 9 +++++---- test/utils.dart | 4 ++++ tool/grind.dart | 3 ++- 5 files changed, 14 insertions(+), 31 deletions(-) delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index 828b9749..4ec6709a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,14 +73,10 @@ jobs: # The versions should be kept up-to-date with the latest LTS Node releases. # They next need to be rotated April 2021. See # https://github.com/nodejs/Release. - # - # TODO(nweiz): Run Node tests on Windows when [this issue][] is fixed. - # - # [this issue]: https://travis-ci.community/t/windows-instances-hanging-before-install/250/28. - &node-tests name: Node tests | Dart stable | Node stable language: node_js - node_js: lts/* + node_js: node install: pub run grinder before-test script: tool/travis/task/node_tests.sh - <<: *node-tests @@ -89,6 +85,8 @@ jobs: - <<: *node-tests name: Node tests | Dart stable | Node Erbium node_js: lts/erbium + - <<: *node-tests + os: windows - <<: *node-tests os: osx - <<: *node-tests diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7efcd0d4..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -build: off - -branches: - only: - - master - # Feature branches beginning with "feature." - - "/^feature\\..*/" - # Semantic version tags and legacy branches of the form "1.2.x". - - "/^\\d+\\.\\d+\\.(\\d+([+-].*)?|x)$/" - -install: -- choco install dart-sdk -- refreshenv -- pub get -- ps: Install-Product node '' -- pub run grinder pkg-npm-dev -- npm install - -# Only run Node tests on Windows because they won't work on Travis. See -# https://travis-ci.community/t/windows-instances-hanging-before-install/250/28. -test_script: pub run test -t node diff --git a/test/node_api_test.dart b/test/node_api_test.dart index 89d27888..f7511a38 100644 --- a/test/node_api_test.dart +++ b/test/node_api_test.dart @@ -18,6 +18,7 @@ import 'hybrid.dart'; import 'node_api/api.dart'; import 'node_api/intercept_stdout.dart'; import 'node_api/utils.dart'; +import 'utils.dart'; String sassPath; @@ -294,7 +295,7 @@ a { "1 │ x {y: }\n" " │ ^\n" " ╵\n" - " $sassPath 1:7 root stylesheet")); + " ${prettyPath(sassPath)} 1:7 root stylesheet")); }); }); @@ -369,7 +370,7 @@ a { "1 │ a {b: }\n" " │ ^\n" " ╵\n" - " $sassPath 1:7 root stylesheet")); + " ${prettyPath(sassPath)} 1:7 root stylesheet")); }); test("sets the line, column, and filename", () { @@ -420,7 +421,7 @@ a { '1 │ a {b: 1 % a}\n' ' │ ^^^^^\n' ' ╵\n' - ' $sassPath 1:7 root stylesheet')); + ' ${prettyPath(sassPath)} 1:7 root stylesheet')); }); test("sets the line, column, and filename", () { @@ -494,7 +495,7 @@ a { "1 │ a {b: }\n" " │ ^\n" " ╵\n" - " $sassPath 1:7 root stylesheet")); + " ${prettyPath(sassPath)} 1:7 root stylesheet")); }); }); } diff --git a/test/utils.dart b/test/utils.dart index 0e6ed37c..086bc01f 100644 --- a/test/utils.dart +++ b/test/utils.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'dart:convert'; +import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:sass/src/io.dart'; @@ -31,3 +32,6 @@ Map embeddedSourceMap(String css) { expect(data.mimeType, equals("application/json")); return jsonDecode(data.contentAsString()) as Map; } + +// Like `p.prettyUri()`, but for a non-URL path. +String prettyPath(String path) => p.prettyUri(p.toUri(path)); diff --git a/tool/grind.dart b/tool/grind.dart index fe32ac86..bbe5a7d7 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -72,7 +72,8 @@ void format() { } @Task('Installs dependencies from npm.') -void npmInstall() => run("npm", arguments: ["install"]); +void npmInstall() => + run(Platform.isWindows ? "npm.cmd" : "npm", arguments: ["install"]); @Task('Runs the tasks that are required for running tests.') @Depends(format, synchronize, "pkg-npm-dev", npmInstall, "pkg-standalone-dev")