mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-27 04:34:59 +01:00
Fix some tests that were broken on Windows
This commit is contained in:
parent
6a1e6e6d12
commit
7a4158dafb
@ -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";
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user