Merge pull request #203 from sass/appveyor

Enable all Node tests on Appveyor
This commit is contained in:
Natalie Weizenbaum 2017-12-08 13:40:20 -08:00 committed by GitHub
commit d8ffd4720a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 10 deletions

View File

@ -28,8 +28,7 @@ install:
test_script:
- ps: >-
If ($env:NODE -eq "true") {
# TODO(nweiz): "-p node" is currently broken. Figure out why.
pub run test -p vm -t node
pub run test -t node
} Else {
pub run test -x node
}

View File

@ -34,6 +34,9 @@ bool get isWindows => false;
/// Returns whether or not stdout is connected to an interactive terminal.
bool get hasTerminal => false;
/// Whether we're running as Node.JS.
bool get isNode => false;
/// The current working directory.
String get currentPath => null;

View File

@ -153,6 +153,8 @@ bool get hasTerminal => _hasTerminal ?? false;
bool get isWindows => _process.platform == 'win32';
bool get isNode => true;
String get currentPath => _process.cwd();
@JS("process.stdout.isTTY")

View File

@ -19,6 +19,8 @@ bool get isWindows => io.Platform.isWindows;
bool get hasTerminal => io.stdout.hasTerminal;
bool get isNode => false;
String get currentPath => io.Directory.current.path;
String readFile(String path) {

View File

@ -170,7 +170,7 @@ RenderError _wrapException(SassException exception) {
.split("\n")
.map((frame) => " $frame")
.join("\n")
: "\n ${p.fromUri(exception.span.sourceUrl ?? '-')} "
: "\n ${p.prettyUri(exception.span.sourceUrl ?? '-')} "
"${exception.span.start.line + 1}:${exception.span.start.column + 1} "
"root stylesheet";

View File

@ -5,6 +5,7 @@
import 'dart:math' as math;
import 'package:charcode/charcode.dart';
import 'package:path/path.dart' as p;
import 'package:string_scanner/string_scanner.dart';
import 'package:tuple/tuple.dart';
@ -732,13 +733,22 @@ abstract class StylesheetParser extends Parser {
return null;
} else {
try {
return new DynamicImport(Uri.parse(url), urlSpan);
return new DynamicImport(_parseImportUrl(url), urlSpan);
} on FormatException catch (error) {
throw new SassFormatException("Invalid URL: ${error.message}", urlSpan);
}
}
}
/// Parses [url] as an import URL.
Uri _parseImportUrl(String url) {
// Backwards-compatibility for implementations that allow absolute Windows
// paths in imports.
if (p.windows.isAbsolute(url)) return p.windows.toUri(url);
return Uri.parse(url);
}
/// Returns whether [url] indicates that an `@import` is a plain CSS import.
bool _isPlainImportUrl(String url) {
if (url.length < 5) return false;

View File

@ -8,6 +8,8 @@ import 'dart:io';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';
import 'package:sass/src/io.dart';
hybridMain(StreamChannel channel) async {
if (!new Directory("build/npm").existsSync()) {
throw "NPM package is not built. Run pub run grinder npm_package.";
@ -43,7 +45,11 @@ hybridMain(StreamChannel channel) async {
/// Ensures that the NPM package is compiled and up-to-date.
///
/// This is safe to call even outside the Dart VM.
Future ensureNpmPackage() {
Future ensureNpmPackage() async {
// spawnHybridUri() doesn't currently work on Windows and Node due to busted
// path handling in the SDK.
if (isNode && isWindows) return;
var channel = spawnHybridUri("/test/ensure_npm_package.dart");
return channel.stream.toList();
await channel.stream.toList();
}

View File

@ -9,6 +9,8 @@ import 'dart:async';
import 'dart:convert';
import 'package:js/js.dart';
// This is unsafe prior to sdk#30098, which landed in Dart 1.25.0-dev.7.0.
import 'package:path/path.dart' as unsafePath;
import 'package:test/test.dart';
import 'package:sass/src/util/path.dart';
@ -203,7 +205,7 @@ a {
var result = sass.renderSync(new RenderOptions(file: sassPath));
expect(result.stats.start, new isInstanceOf<int>());
expect(result.stats.end, new isInstanceOf<int>());
expect(result.stats.start, lessThan(result.stats.end));
expect(result.stats.start, lessThanOrEqualTo(result.stats.end));
expect(result.stats.duration,
equals(result.stats.end - result.stats.start));
});
@ -260,7 +262,7 @@ a {
"Error: Expected expression.\n"
"a {b: }\n"
" ^\n"
" $sassPath 1:7 root stylesheet");
" ${tracePath(sassPath)} 1:7 root stylesheet");
});
test("sets the line, column, and filename", () {
@ -308,7 +310,7 @@ a {
expect(
error,
toStringAndMessageEqual('Undefined operation "1 % a".\n'
' $sassPath 1:7 root stylesheet'));
' ${tracePath(sassPath)} 1:7 root stylesheet'));
});
test("has a useful formatted message", () async {
@ -317,7 +319,7 @@ a {
'Error: Undefined operation "1 % a".\n'
'a {b: 1 % a}\n'
' ^^^^^\n'
' $sassPath 1:7 root stylesheet');
' ${tracePath(sassPath)} 1:7 root stylesheet');
});
test("sets the line, column, and filename", () {
@ -376,3 +378,9 @@ a {
});
});
}
/// Returns [path] in the format it appears in formatted stack traces.
///
/// Stack traces use the global `path` context, which is broken on Node prior to
/// Dart 1.25.0-dev.7.0.
String tracePath(String path) => unsafePath.prettyUri(p.toUri(path));