diff --git a/CHANGELOG.md b/CHANGELOG.md index f7b5f80fa..9269480b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## 1.80.0 + +* `@import` is now officially deprecated, as are global built-in functions that + are available within built-in modules. See [the Sass blog post] for more + details on the deprecation process. + +[the Sass blog post]: https://sass-lang.com/blog/import-is-deprecated/ + +### Embedded Host + +* Fix an error that would sometimes occur when deprecation warnings were + emitted when using a custom importer with the legacy API. + ## 1.79.6 * Fix a bug where Sass would add an extra `*/` after loud comments with diff --git a/lib/src/callable/async_built_in.dart b/lib/src/callable/async_built_in.dart index 2c764ee0c..4e479c148 100644 --- a/lib/src/callable/async_built_in.dart +++ b/lib/src/callable/async_built_in.dart @@ -99,8 +99,9 @@ class AsyncBuiltInCallable implements AsyncCallable { /// available as function [name] in built-in module [module]. void warnForGlobalBuiltIn(String module, String name) { warnForDeprecation( - 'Global built-in functions will be deprecated in the future.\n' - 'Remove the --future-deprecation=global-builtin flag to silence this ' - 'warning for now.', + 'Global built-in functions are deprecated and will be removed in Dart ' + 'Sass 3.0.0.\n' + 'Use $module.$name instead.\n\n' + 'More info and automated migrator: https://sass-lang.com/d/import', Deprecation.globalBuiltin); } diff --git a/lib/src/deprecation.dart b/lib/src/deprecation.dart index ca50b3261..e7c4e6a4e 100644 --- a/lib/src/deprecation.dart +++ b/lib/src/deprecation.dart @@ -15,7 +15,7 @@ enum Deprecation { // DO NOT EDIT. This section was generated from the language repo. // See tool/grind/generate_deprecations.dart for details. // - // Checksum: 0243e0f7ee85127d6e1bda5c08e363509959e758 + // Checksum: 47c97f7824eb25d7f1e64e3230938b88330d40b4 /// Deprecation for passing a string directly to meta.call(). callString('call-string', @@ -114,10 +114,11 @@ enum Deprecation { deprecatedIn: '1.79.0', description: 'Legacy JS API.'), /// Deprecation for @import rules. - import.future('import', description: '@import rules.'), + import('import', deprecatedIn: '1.80.0', description: '@import rules.'), /// Deprecation for global built-in functions that are available in sass: modules. - globalBuiltin.future('global-builtin', + globalBuiltin('global-builtin', + deprecatedIn: '1.80.0', description: 'Global built-in functions that are available in sass: modules.'), diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index df28da881..3fab4e0ba 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -1057,9 +1057,9 @@ abstract class StylesheetParser extends Parser { if (argument is DynamicImport) { logger.warnForDeprecation( Deprecation.import, - 'Sass @import rules will be deprecated in the future.\n' - 'Remove the --future-deprecation=import flag to silence this ' - 'warning for now.', + 'Sass @import rules are deprecated and will be removed in Dart ' + 'Sass 3.0.0.\n\n' + 'More info and automated migrator: https://sass-lang.com/d/import', span: argument.span); } if ((_inControlDirective || _inMixin) && argument is DynamicImport) { diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index 1afef8b15..86f01f5d2 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + +* No user-visible changes. + ## 0.2.6 * No user-visible changes. diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index a42bac365..de957f8d0 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.2.6", + "version": "0.3.0", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 3f209ff96..c95877073 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 13.1.0 + +* No user-visible changes. + ## 13.0.1 * Fix a bug where `LoudComment`s parsed from the indented syntax would include diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 352f8442f..675934062 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 13.0.1 +version: 13.1.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - sass: 1.79.6 + sass: 1.80.0 dev_dependencies: dartdoc: ^8.0.14 diff --git a/pubspec.yaml b/pubspec.yaml index d9093b1e2..33ce827c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.79.6 +version: 1.80.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass diff --git a/test/cli/dart/errors_test.dart b/test/cli/dart/errors_test.dart index a2318f0db..85c269865 100644 --- a/test/cli/dart/errors_test.dart +++ b/test/cli/dart/errors_test.dart @@ -16,7 +16,7 @@ void main() { sharedTests(runSass); test("for package urls", () async { - await d.file("test.scss", "@import 'package:nope/test';").create(); + await d.file("test.scss", "@use 'package:nope/test';").create(); var sass = await runSass(["--no-unicode", "test.scss"]); expect( @@ -24,10 +24,10 @@ void main() { emitsInOrder([ "Error: Can't find stylesheet to import.", " ,", - "1 | @import 'package:nope/test';", - " | ^^^^^^^^^^^^^^^^^^^", + "1 | @use 'package:nope/test';", + " | ^^^^^^^^^^^^^^^^^^^^^^^^", " '", - " test.scss 1:9 root stylesheet" + " test.scss 1:1 root stylesheet" ])); await sass.shouldExit(65); }); diff --git a/test/cli/node/errors_test.dart b/test/cli/node/errors_test.dart index 25e5d8dc9..a20e4905c 100644 --- a/test/cli/node/errors_test.dart +++ b/test/cli/node/errors_test.dart @@ -18,7 +18,7 @@ void main() { sharedTests(runSass); test("for package urls", () async { - await d.file("test.scss", "@import 'package:nope/test';").create(); + await d.file("test.scss", "@use 'package:nope/test';").create(); var sass = await runSass(["--no-unicode", "test.scss"]); expect( @@ -26,10 +26,10 @@ void main() { emitsInOrder([ "Error: \"package:\" URLs aren't supported on this platform.", " ,", - "1 | @import 'package:nope/test';", - " | ^^^^^^^^^^^^^^^^^^^", + "1 | @use 'package:nope/test';", + " | ^^^^^^^^^^^^^^^^^^^^^^^^", " '", - " test.scss 1:9 root stylesheet" + " test.scss 1:1 root stylesheet" ])); await sass.shouldExit(65); }); diff --git a/test/cli/shared.dart b/test/cli/shared.dart index 63c990685..d9264bde2 100644 --- a/test/cli/shared.dart +++ b/test/cli/shared.dart @@ -110,7 +110,7 @@ void sharedTests( group("can import files", () { test("relative to the entrypoint", () async { - await d.file("test.scss", "@import 'dir/test'").create(); + await d.file("test.scss", "@use 'dir/test'").create(); await d.dir("dir", [d.file("test.scss", "a {b: 1 + 2}")]).create(); @@ -119,7 +119,7 @@ void sharedTests( }); test("from the load path", () async { - await d.file("test.scss", "@import 'test2'").create(); + await d.file("test.scss", "@use 'test2'").create(); await d.dir("dir", [d.file("test2.scss", "a {b: c}")]).create(); @@ -129,8 +129,8 @@ void sharedTests( test("from SASS_PATH", () async { await d.file("test.scss", """ - @import 'test2'; - @import 'test3'; + @use 'test2'; + @use 'test3'; """).create(); await d.dir("dir2", [d.file("test2.scss", "a {b: c}")]).create(); @@ -145,12 +145,12 @@ void sharedTests( // Regression test for #369 test("from within a directory, relative to a file on the load path", () async { - await d.dir( - "dir1", [d.file("test.scss", "@import 'subdir/test2'")]).create(); + await d + .dir("dir1", [d.file("test.scss", "@use 'subdir/test2'")]).create(); await d.dir("dir2", [ d.dir("subdir", [ - d.file("test2.scss", "@import 'test3'"), + d.file("test2.scss", "@use 'test3'"), d.file("test3.scss", "a {b: c}") ]) ]).create(); @@ -160,7 +160,7 @@ void sharedTests( }); test("relative in preference to from the load path", () async { - await d.file("test.scss", "@import 'test2'").create(); + await d.file("test.scss", "@use 'test2'").create(); await d.file("test2.scss", "x {y: z}").create(); await d.dir("dir", [d.file("test2.scss", "a {b: c}")]).create(); @@ -170,7 +170,7 @@ void sharedTests( }); test("in load path order", () async { - await d.file("test.scss", "@import 'test2'").create(); + await d.file("test.scss", "@use 'test2'").create(); await d.dir("dir1", [d.file("test2.scss", "a {b: c}")]).create(); await d.dir("dir2", [d.file("test2.scss", "x {y: z}")]).create(); @@ -181,7 +181,7 @@ void sharedTests( }); test("from the load path in preference to from SASS_PATH", () async { - await d.file("test.scss", "@import 'test2'").create(); + await d.file("test.scss", "@use 'test2'").create(); await d.dir("dir1", [d.file("test2.scss", "a {b: c}")]).create(); await d.dir("dir2", [d.file("test2.scss", "x {y: z}")]).create(); @@ -192,7 +192,7 @@ void sharedTests( }); test("in SASS_PATH order", () async { - await d.file("test.scss", "@import 'test2'").create(); + await d.file("test.scss", "@use 'test2'").create(); await d.dir("dir1", [d.file("test2.scss", "a {b: c}")]).create(); await d.dir("dir2", [d.file("test2.scss", "x {y: z}")]).create(); @@ -224,6 +224,8 @@ void sharedTests( "grandparent", "--load-path", "grandparent/parent", + "--silence-deprecation", + "import", "test.scss" ], equalsIgnoringWhitespace("a { b: c; } a { b: c; }")); }); @@ -240,8 +242,13 @@ void sharedTests( d.file("_library.import.scss", "a { b: import-only }") ]).create(); - await expectCompiles(["--load-path", "load-path", "test.scss"], - equalsIgnoringWhitespace("a { b: regular; } a { b: import-only; }")); + await expectCompiles([ + "--load-path", + "load-path", + "--silence-deprecation", + "import", + "test.scss" + ], equalsIgnoringWhitespace("a { b: regular; } a { b: import-only; }")); }); }); @@ -487,7 +494,14 @@ void sharedTests( await d.file("test.scss", "@import 'other'").create(); await d.dir("dir", [d.file("_other.scss", "#{blue} {x: y}")]).create(); - var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]); + var sass = await runSass([ + "--quiet-deps", + "-I", + "dir", + "--silence-deprecation", + "import", + "test.scss" + ]); expect(sass.stderr, emitsDone); await sass.shouldExit(0); }); @@ -501,7 +515,14 @@ void sharedTests( """) ]).create(); - var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]); + var sass = await runSass([ + "--quiet-deps", + "-I", + "dir", + "--silence-deprecation", + "import", + "test.scss" + ]); expect(sass.stderr, emitsDone); await sass.shouldExit(0); }); @@ -637,12 +658,15 @@ void sharedTests( group("with a bunch of deprecation warnings", () { setUp(() async { await d.file("test.scss", r""" - $_: call("inspect", null); - $_: call("rgb", 0, 0, 0); - $_: call("nth", null, 1); - $_: call("join", null, null); - $_: call("if", true, 1, 2); - $_: call("hsl", 0, 100%, 100%); + @use "sass:list"; + @use "sass:meta"; + + $_: meta.call("inspect", null); + $_: meta.call("rgb", 0, 0, 0); + $_: meta.call("nth", null, 1); + $_: meta.call("join", null, null); + $_: meta.call("if", true, 1, 2); + $_: meta.call("hsl", 0, 100%, 100%); $_: 1/2; $_: 1/3; @@ -877,7 +901,8 @@ void sharedTests( expect(sass.stdout, emitsDone); await sass.shouldExit(65); }); - }); + // Skipping while no future deprecations exist + }, skip: true); test("doesn't unassign variables", () async { // This is a regression test for one of the strangest errors I've ever @@ -896,7 +921,8 @@ void sharedTests( await d.file("_midstream.scss", "@forward 'upstream'").create(); await d.file("_upstream.scss", r"$c: g").create(); - var sass = await runSass(["input.scss", "output.css"]); + var sass = await runSass( + ["--silence-deprecation", "import", "input.scss", "output.css"]); await sass.shouldExit(0); await d.file("output.css", equalsIgnoringWhitespace(""" diff --git a/test/cli/shared/deprecations.dart b/test/cli/shared/deprecations.dart index 03f1b4dc2..a956a9572 100644 --- a/test/cli/shared/deprecations.dart +++ b/test/cli/shared/deprecations.dart @@ -29,7 +29,7 @@ void sharedTests(Future runSass(Iterable arguments)) { var sass = await runSass(["--silence-deprecation=import", "test.scss"]); expect(sass.stderr, emits(contains("Future import deprecation"))); await sass.shouldExit(0); - }); + }, skip: true); test("for an active future deprecation", () async { var sass = await runSass([ @@ -39,7 +39,7 @@ void sharedTests(Future runSass(Iterable arguments)) { ]); expect(sass.stderr, emits(contains("Conflicting options for future"))); await sass.shouldExit(0); - }); + }, skip: true); test("in watch mode", () async { var sass = await runSass([ @@ -183,7 +183,7 @@ void sharedTests(Future runSass(Iterable arguments)) { var sass = await runSass(["--fatal-deprecation=import", "test.scss"]); expect(sass.stderr, emits(contains("Future import deprecation"))); await sass.shouldExit(0); - }); + }, skip: true); test("for a silent deprecation", () async { var sass = await runSass([ @@ -493,5 +493,6 @@ void sharedTests(Future runSass(Iterable arguments)) { }); }); }); - }); + // Skipping while no future deprecations exist + }, skip: true); } diff --git a/test/cli/shared/source_maps.dart b/test/cli/shared/source_maps.dart index 75035b3b4..a2d0ad2e4 100644 --- a/test/cli/shared/source_maps.dart +++ b/test/cli/shared/source_maps.dart @@ -43,7 +43,7 @@ void sharedTests(Future runSass(Iterable arguments)) { group("with multiple sources", () { setUp(() async { await d.file("test.scss", """ - @import 'dir/other'; + @use 'dir/other'; x {y: z} """).create(); await d.dir("dir", [d.file("other.scss", "a {b: 1 + 2}")]).create(); @@ -96,7 +96,7 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("when imported with the same case", () async { - await d.file("importer.scss", "@import 'TeSt.scss'").create(); + await d.file("importer.scss", "@use 'TeSt.scss'").create(); await (await runSass(["importer.scss", "out.css"])).shouldExit(0); expect(_readJson("out.css.map"), containsPair("sources", ["TeSt.scss"])); }); @@ -109,7 +109,7 @@ void sharedTests(Future runSass(Iterable arguments)) { }, testOn: "windows"); test("when imported with a different case", () async { - await d.file("importer.scss", "@import 'test.scss'").create(); + await d.file("importer.scss", "@use 'test.scss'").create(); await (await runSass(["importer.scss", "out.css"])).shouldExit(0); expect(_readJson("out.css.map"), containsPair("sources", ["TeSt.scss"])); }, testOn: "windows"); diff --git a/test/cli/shared/update.dart b/test/cli/shared/update.dart index 73b8a21df..260c1d132 100644 --- a/test/cli/shared/update.dart +++ b/test/cli/shared/update.dart @@ -43,7 +43,7 @@ void sharedTests(Future runSass(Iterable arguments)) { test("whose source was transitively modified", () async { await d.file("other.scss", "a {b: c}").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await update(["test.scss:out.css"]); expect(sass.stdout, emits(endsWith('Compiled test.scss to out.css.'))); @@ -177,26 +177,26 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("with a missing import", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var message = "Error: Can't find stylesheet to import."; var sass = await update(["test.scss:out.css"]); expect(sass.stderr, emits(message)); - expect(sass.stderr, emitsThrough(contains("test.scss 1:9"))); + expect(sass.stderr, emitsThrough(contains("test.scss 1:1"))); await sass.shouldExit(65); await d.file("out.css", contains(message)).validate(); }); test("with a conflicting import", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.file("other.scss", "a {b: c}").create(); await d.file("_other.scss", "x {y: z}").create(); var message = "Error: It's not clear which file to import. Found:"; var sass = await update(["test.scss:out.css"]); expect(sass.stderr, emits(message)); - expect(sass.stderr, emitsThrough(contains("test.scss 1:9"))); + expect(sass.stderr, emitsThrough(contains("test.scss 1:1"))); await sass.shouldExit(65); await d.file("out.css", contains(message)).validate(); @@ -257,7 +257,7 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("when an import is removed", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.file("_other.scss", "a {b: c}").create(); await (await update(["test.scss:out.css"])).shouldExit(0); await d.file("out.css", anything).validate(); @@ -266,7 +266,7 @@ void sharedTests(Future runSass(Iterable arguments)) { d.file("_other.scss").io.deleteSync(); var sass = await update(["test.scss:out.css"]); expect(sass.stderr, emits(message)); - expect(sass.stderr, emitsThrough(contains("test.scss 1:9"))); + expect(sass.stderr, emitsThrough(contains("test.scss 1:1"))); await sass.shouldExit(65); await d.file("out.css", contains(message)).validate(); diff --git a/test/cli/shared/watch.dart b/test/cli/shared/watch.dart index b80b33e64..f2bfc6d12 100644 --- a/test/cli/shared/watch.dart +++ b/test/cli/shared/watch.dart @@ -208,7 +208,8 @@ void sharedTests(Future runSass(Iterable arguments)) { await d.file("_other.scss", "a {b: c}").create(); await d.file("test.scss", "@import 'other'").create(); - var sass = await watch(["test.scss:out.css"]); + var sass = await watch( + ["--silence-deprecation", "import", "test.scss:out.css"]); await expectLater( sass.stdout, emits(endsWith('Compiled test.scss to out.css.'))); await expectLater(sass.stdout, _watchingForChanges); @@ -361,7 +362,7 @@ void sharedTests(Future runSass(Iterable arguments)) { // Regression test for #550 test("with an error that's later fixed", () async { await d.file("_other.scss", "a {b: c}").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await watch(["test.scss:out.css"]); await expectLater( @@ -373,7 +374,7 @@ void sharedTests(Future runSass(Iterable arguments)) { await expectLater( sass.stderr, emits('Error: Expected expression.')); await expectLater( - sass.stderr, emitsThrough(contains('test.scss 1:9'))); + sass.stderr, emitsThrough(contains('test.scss 1:1'))); await tickIfPoll(); await d.file("_other.scss", "q {r: s}").create(); @@ -466,7 +467,7 @@ void sharedTests(Future runSass(Iterable arguments)) { group("when its dependency is deleted", () { test("and updates the output", () async { await d.file("_other.scss", "a {b: c}").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await watch(["test.scss:out.css"]); await expectLater( @@ -478,7 +479,7 @@ void sharedTests(Future runSass(Iterable arguments)) { d.file("_other.scss").io.deleteSync(); await expectLater(sass.stderr, emits(message)); await expectLater( - sass.stderr, emitsThrough(contains('test.scss 1:9'))); + sass.stderr, emitsThrough(contains('test.scss 1:1'))); await sass.kill(); await d.file("out.css", contains(message)).validate(); @@ -486,7 +487,7 @@ void sharedTests(Future runSass(Iterable arguments)) { test("but another is available", () async { await d.file("_other.scss", "a {b: c}").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.dir("dir", [d.file("_other.scss", "x {y: z}")]).create(); var sass = await watch(["-I", "dir", "test.scss:out.css"]); @@ -508,7 +509,7 @@ void sharedTests(Future runSass(Iterable arguments)) { test("which resolves a conflict", () async { await d.file("_other.scss", "a {b: c}").create(); await d.file("_other.sass", "x\n y: z").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await watch(["test.scss:out.css"]); await expectLater(sass.stderr, @@ -530,13 +531,13 @@ void sharedTests(Future runSass(Iterable arguments)) { group("when a dependency is added", () { group("that was missing", () { test("relative to the file", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await watch(["test.scss:out.css"]); await expectLater(sass.stderr, emits("Error: Can't find stylesheet to import.")); await expectLater( - sass.stderr, emitsThrough(contains("test.scss 1:9"))); + sass.stderr, emitsThrough(contains("test.scss 1:1"))); await expectLater(sass.stdout, _watchingForChanges); await tickIfPoll(); @@ -551,14 +552,14 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("on a load path", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.dir("dir").create(); var sass = await watch(["-I", "dir", "test.scss:out.css"]); await expectLater(sass.stderr, emits("Error: Can't find stylesheet to import.")); await expectLater( - sass.stderr, emitsThrough(contains("test.scss 1:9"))); + sass.stderr, emitsThrough(contains("test.scss 1:1"))); await expectLater(sass.stdout, _watchingForChanges); await tickIfPoll(); @@ -573,14 +574,14 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("on a load path that was created", () async { - await d.dir( - "dir1", [d.file("test.scss", "@import 'other'")]).create(); + await d + .dir("dir1", [d.file("test.scss", "@use 'other'")]).create(); var sass = await watch(["-I", "dir2", "dir1:out"]); await expectLater(sass.stderr, emits("Error: Can't find stylesheet to import.")); await expectLater(sass.stderr, - emitsThrough(contains("${p.join('dir1', 'test.scss')} 1:9"))); + emitsThrough(contains("${p.join('dir1', 'test.scss')} 1:1"))); await expectLater(sass.stdout, _watchingForChanges); await tickIfPoll(); @@ -597,7 +598,7 @@ void sharedTests(Future runSass(Iterable arguments)) { test("that conflicts with the previous dependency", () async { await d.file("_other.scss", "a {b: c}").create(); - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); var sass = await watch(["test.scss:out.css"]); await expectLater( @@ -615,7 +616,7 @@ void sharedTests(Future runSass(Iterable arguments)) { group("that overrides the previous dependency", () { test("on an import path", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.dir("dir2", [d.file("_other.scss", "a {b: c}")]).create(); await d.dir("dir1").create(); @@ -637,7 +638,7 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("because it's relative", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.dir("dir", [d.file("_other.scss", "a {b: c}")]).create(); var sass = await watch(["-I", "dir", "test.scss:out.css"]); @@ -657,7 +658,7 @@ void sharedTests(Future runSass(Iterable arguments)) { }); test("because it's not an index", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d .dir("other", [d.file("_index.scss", "a {b: c}")]).create(); @@ -755,7 +756,7 @@ void sharedTests(Future runSass(Iterable arguments)) { test( "when a potential dependency that's not actually imported is added", () async { - await d.file("test.scss", "@import 'other'").create(); + await d.file("test.scss", "@use 'other'").create(); await d.file("_other.scss", "a {b: c}").create(); await d.dir("dir").create(); diff --git a/test/dart_api/importer_test.dart b/test/dart_api/importer_test.dart index cc8ca08cb..0b47eccde 100644 --- a/test/dart_api/importer_test.dart +++ b/test/dart_api/importer_test.dart @@ -16,8 +16,8 @@ import 'test_importer.dart'; import '../utils.dart'; void main() { - test("uses an importer to resolve an @import", () { - var css = compileString('@import "orange";', importers: [ + test("uses an importer to resolve a @use", () { + var css = compileString('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { var color = url.path; return ImporterResult('.$color {color: $color}', indented: false); @@ -28,7 +28,7 @@ void main() { }); test("passes the canonicalized URL to the importer", () { - var css = compileString('@import "orange";', importers: [ + var css = compileString('@use "orange";', importers: [ TestImporter((url) => Uri.parse('u:blue'), (url) { var color = url.path; return ImporterResult('.$color {color: $color}', indented: false); @@ -63,7 +63,7 @@ void main() { test("resolves URLs relative to the pre-canonicalized URL", () { var times = 0; - var css = compileString('@import "foo:bar/baz";', + var css = compileString('@use "foo:bar/baz";', importers: [ TestImporter( expectAsync1((url) { @@ -95,7 +95,7 @@ void main() { group("the imported URL", () { // Regression test for #1137. test("isn't changed if it's root-relative", () { - compileString('@import "/orange";', importers: [ + compileString('@use "/orange";', importers: [ TestImporter(expectAsync1((url) { expect(url, equals(Uri.parse("/orange"))); return Uri.parse("u:$url"); @@ -116,7 +116,7 @@ void main() { group("the containing URL", () { test("is null for a potentially canonical scheme", () { late TestImporter importer; - compileString('@import "u:orange";', + compileString('@use "u:orange";', importers: [ importer = TestImporter(expectAsync1((url) { expect(importer.publicContainingUrl, isNull); @@ -128,7 +128,7 @@ void main() { test("throws an error outside canonicalize", () { late TestImporter importer; - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ importer = TestImporter((url) => Uri.parse("u:$url"), expectAsync1((url) { expect(() => importer.publicContainingUrl, throwsStateError); @@ -140,7 +140,7 @@ void main() { group("for a non-canonical scheme", () { test("is set to the original URL", () { late TestImporter importer; - compileString('@import "u:orange";', + compileString('@use "u:orange";', importers: [ importer = TestImporter(expectAsync1((url) { expect(importer.publicContainingUrl, @@ -154,7 +154,7 @@ void main() { test("is null if the original URL is null", () { late TestImporter importer; - compileString('@import "u:orange";', importers: [ + compileString('@use "u:orange";', importers: [ importer = TestImporter(expectAsync1((url) { expect(importer.publicContainingUrl, isNull); return url.replace(scheme: 'x'); @@ -167,7 +167,7 @@ void main() { group("for a schemeless load", () { test("is set to the original URL", () { late TestImporter importer; - compileString('@import "orange";', + compileString('@use "orange";', importers: [ importer = TestImporter(expectAsync1((url) { expect(importer.publicContainingUrl, @@ -180,7 +180,7 @@ void main() { test("is null if the original URL is null", () { late TestImporter importer; - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ importer = TestImporter(expectAsync1((url) { expect(importer.publicContainingUrl, isNull); return Uri.parse("u:$url"); @@ -194,7 +194,7 @@ void main() { "throws an error if the importer returns a canonical URL with a " "non-canonical scheme", () { expect( - () => compileString('@import "orange";', importers: [ + () => compileString('@use "orange";', importers: [ TestImporter(expectAsync1((url) => Uri.parse("u:$url")), (_) => ImporterResult('', indented: false), nonCanonicalSchemes: {'u'}) @@ -207,7 +207,7 @@ void main() { }); test("uses an importer's source map URL", () { - var result = compileStringToResult('@import "orange";', + var result = compileStringToResult('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { var color = url.path; @@ -221,7 +221,7 @@ void main() { }); test("uses a data: source map URL if the importer doesn't provide one", () { - var result = compileStringToResult('@import "orange";', + var result = compileStringToResult('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { var color = url.path; @@ -238,7 +238,7 @@ void main() { test("wraps an error in canonicalize()", () { expect(() { - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ TestImporter((url) { throw "this import is bad actually"; }, expectNever1) @@ -253,7 +253,7 @@ void main() { test("wraps an error in load()", () { expect(() { - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { throw "this import is bad actually"; }) @@ -268,7 +268,7 @@ void main() { test("prefers .message to .toString() for an importer error", () { expect(() { - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { throw FormatException("bad format somehow"); }) @@ -284,7 +284,7 @@ void main() { test("avoids importer when only load() returns null", () { expect(() { - compileString('@import "orange";', importers: [ + compileString('@use "orange";', importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) => null) ]); }, throwsA(predicate((error) { @@ -297,7 +297,7 @@ void main() { group("compileString()'s importer option", () { test("loads relative imports from the entrypoint", () { - var css = compileString('@import "orange";', + var css = compileString('@use "orange";', importer: TestImporter((url) => Uri.parse("u:$url"), (url) { var color = url.path; return ImporterResult('.$color {color: $color}', indented: false); @@ -307,7 +307,7 @@ void main() { }); test("loads imports relative to the entrypoint's URL", () { - var css = compileString('@import "baz/qux";', + var css = compileString('@use "baz/qux";', importer: TestImporter((url) => url.resolve("bang"), (url) { return ImporterResult('a {result: "${url.path}"}', indented: false); }), @@ -317,7 +317,7 @@ void main() { }); test("doesn't load absolute imports", () { - var css = compileString('@import "u:orange";', + var css = compileString('@use "u:orange";', importer: TestImporter((_) => throw "Should not be called", (_) => throw "Should not be called"), importers: [ @@ -331,13 +331,13 @@ void main() { }); test("doesn't load from other importers", () { - var css = compileString('@import "u:midstream";', + var css = compileString('@use "u:midstream";', importer: TestImporter((_) => throw "Should not be called", (_) => throw "Should not be called"), importers: [ TestImporter((url) => url, (url) { if (url.path == "midstream") { - return ImporterResult("@import 'orange';", indented: false); + return ImporterResult("@use 'orange';", indented: false); } else { var color = url.path; return ImporterResult('.$color {color: $color}', diff --git a/test/dart_api/logger_test.dart b/test/dart_api/logger_test.dart index 96ee56ac8..2c069a693 100644 --- a/test/dart_api/logger_test.dart +++ b/test/dart_api/logger_test.dart @@ -194,7 +194,7 @@ void main() { test("from an importer", () { var mustBeCalled = expectAsync0(() {}); - compileString("@import 'foo';", importers: [ + compileString("@use 'foo';", importers: [ TestImporter((url) => Uri.parse("u:$url"), (url) { warn("heck"); return ImporterResult("", indented: false); @@ -204,11 +204,11 @@ void main() { expect(message, equals("heck")); expect(span!.start.line, equals(0)); - expect(span.start.column, equals(8)); + expect(span.start.column, equals(0)); expect(span.end.line, equals(0)); - expect(span.end.column, equals(13)); + expect(span.end.column, equals(10)); - expect(trace!.frames.first.member, equals('@import')); + expect(trace!.frames.first.member, equals('@use')); expect(deprecation, isFalse); mustBeCalled(); })); diff --git a/test/dart_api_test.dart b/test/dart_api_test.dart index 9c9c5a3d1..5337e4903 100644 --- a/test/dart_api_test.dart +++ b/test/dart_api_test.dart @@ -21,7 +21,7 @@ void main() { group("importers", () { test("is used to resolve imports", () async { await d.dir("subdir", [d.file("subtest.scss", "a {b: c}")]).create(); - await d.file("test.scss", '@import "subtest.scss";').create(); + await d.file("test.scss", '@use "subtest.scss";').create(); var css = compile(d.path("test.scss"), importers: [FilesystemImporter(d.path('subdir'))]); @@ -33,7 +33,7 @@ void main() { .dir("first", [d.file("other.scss", "a {b: from-first}")]).create(); await d .dir("second", [d.file("other.scss", "a {b: from-second}")]).create(); - await d.file("test.scss", '@import "other";').create(); + await d.file("test.scss", '@use "other";').create(); var css = compile(d.path("test.scss"), importers: [ FilesystemImporter(d.path('first')), @@ -46,7 +46,7 @@ void main() { group("loadPaths", () { test("is used to import file: URLs", () async { await d.dir("subdir", [d.file("subtest.scss", "a {b: c}")]).create(); - await d.file("test.scss", '@import "subtest.scss";').create(); + await d.file("test.scss", '@use "subtest.scss";').create(); var css = compile(d.path("test.scss"), loadPaths: [d.path('subdir')]); expect(css, equals("a {\n b: c;\n}")); @@ -54,7 +54,7 @@ void main() { test("can import partials", () async { await d.dir("subdir", [d.file("_subtest.scss", "a {b: c}")]).create(); - await d.file("test.scss", '@import "subtest.scss";').create(); + await d.file("test.scss", '@use "subtest.scss";').create(); var css = compile(d.path("test.scss"), loadPaths: [d.path('subdir')]); expect(css, equals("a {\n b: c;\n}")); @@ -62,7 +62,7 @@ void main() { test("adds a .scss extension", () async { await d.dir("subdir", [d.file("subtest.scss", "a {b: c}")]).create(); - await d.file("test.scss", '@import "subtest";').create(); + await d.file("test.scss", '@use "subtest";').create(); var css = compile(d.path("test.scss"), loadPaths: [d.path('subdir')]); expect(css, equals("a {\n b: c;\n}")); @@ -70,7 +70,7 @@ void main() { test("adds a .sass extension", () async { await d.dir("subdir", [d.file("subtest.sass", "a\n b: c")]).create(); - await d.file("test.scss", '@import "subtest";').create(); + await d.file("test.scss", '@use "subtest";').create(); var css = compile(d.path("test.scss"), loadPaths: [d.path('subdir')]); expect(css, equals("a {\n b: c;\n}")); @@ -81,7 +81,7 @@ void main() { .dir("first", [d.file("other.scss", "a {b: from-first}")]).create(); await d .dir("second", [d.file("other.scss", "a {b: from-second}")]).create(); - await d.file("test.scss", '@import "other";').create(); + await d.file("test.scss", '@use "other";').create(); var css = compile(d.path("test.scss"), loadPaths: [d.path('first'), d.path('second')]); @@ -93,9 +93,7 @@ void main() { test("is used to import package: URLs", () async { await d.dir("subdir", [d.file("test.scss", "a {b: 1 + 2}")]).create(); - await d - .file("test.scss", '@import "package:fake_package/test";') - .create(); + await d.file("test.scss", '@use "package:fake_package/test";').create(); var config = PackageConfig([Package('fake_package', p.toUri(d.path('subdir/')))]); @@ -105,13 +103,11 @@ void main() { test("can resolve relative paths in a package", () async { await d.dir("subdir", [ - d.file("test.scss", "@import 'other'"), + d.file("test.scss", "@use 'other'"), d.file("_other.scss", "a {b: 1 + 2}"), ]).create(); - await d - .file("test.scss", '@import "package:fake_package/test";') - .create(); + await d.file("test.scss", '@use "package:fake_package/test";').create(); var config = PackageConfig([Package('fake_package', p.toUri(d.path('subdir/')))]); @@ -121,7 +117,7 @@ void main() { test("doesn't import a package URL from a missing package", () async { await d - .file("test.scss", '@import "package:fake_package/test_aux";') + .file("test.scss", '@use "package:fake_package/test_aux";') .create(); expect( @@ -135,7 +131,7 @@ void main() { await d.dir( "subdir", [d.file("other.scss", "a {b: from-load-path}")]).create(); await d.file("other.scss", "a {b: from-relative}").create(); - await d.file("test.scss", '@import "other";').create(); + await d.file("test.scss", '@use "other";').create(); var css = compile(d.path("test.scss"), importers: [FilesystemImporter(d.path('subdir'))]); @@ -150,7 +146,7 @@ void main() { await d .dir("other", [d.file("other.scss", "a {b: from-other}")]).create(); - var css = compileString('@import "other";', + var css = compileString('@use "other";', importer: FilesystemImporter(d.path('original')), url: p.toUri(d.path('original/test.scss')), importers: [FilesystemImporter(d.path('other'))]); @@ -158,7 +154,7 @@ void main() { }); test("importer order is preserved for absolute imports", () { - var css = compileString('@import "second:other";', importers: [ + var css = compileString('@use "second:other";', importers: [ TestImporter((url) => url.scheme == 'first' ? url : null, (url) => ImporterResult('a {from: first}', indented: false)), // This importer should only be invoked once, because when the @@ -167,7 +163,7 @@ void main() { TestImporter( expectAsync1((url) => url.scheme == 'second' ? url : null, count: 1), - (url) => ImporterResult('@import "first:other";', indented: false)), + (url) => ImporterResult('@use "first:other";', indented: false)), ]); expect(css, equals("a {\n from: first;\n}")); }); @@ -177,7 +173,7 @@ void main() { [d.file("other.scss", "a {b: from-load-path}")]).create(); await d.dir( "importer", [d.file("other.scss", "a {b: from-importer}")]).create(); - await d.file("test.scss", '@import "other";').create(); + await d.file("test.scss", '@use "other";').create(); var css = compile(d.path("test.scss"), importers: [FilesystemImporter(d.path('importer'))], @@ -190,9 +186,7 @@ void main() { [d.file("other.scss", "a {b: from-package-config}")]).create(); await d.dir( "importer", [d.file("other.scss", "a {b: from-importer}")]).create(); - await d - .file("test.scss", '@import "package:fake_package/other";') - .create(); + await d.file("test.scss", '@use "package:fake_package/other";').create(); var css = compile(d.path("test.scss"), importers: [ @@ -269,7 +263,8 @@ a { test("contains a URL loaded via @import", () async { await d.file("_other.scss", "a {b: c}").create(); await d.file("input.scss", "@import 'other';").create(); - var result = compileToResult(d.path('input.scss')); + var result = compileToResult(d.path('input.scss'), + silenceDeprecations: [Deprecation.import]); expect(result.loadedUrls, contains(p.toUri(d.path('_other.scss')))); }); @@ -306,7 +301,8 @@ a { @use 'sass:meta'; @include meta.load-css('venus'); """).create(); - var result = compileToResult(d.path('mercury.scss')); + var result = compileToResult(d.path('mercury.scss'), + silenceDeprecations: [Deprecation.import]); expect( result.loadedUrls, unorderedEquals([ diff --git a/test/embedded/file_importer_test.dart b/test/embedded/file_importer_test.dart index 3fd68af7c..61c8e1a42 100644 --- a/test/embedded/file_importer_test.dart +++ b/test/embedded/file_importer_test.dart @@ -25,7 +25,7 @@ void main() { late OutboundMessage_FileImportRequest request; setUp(() async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..fileImporterId = 1 ])); @@ -64,7 +64,7 @@ void main() { late OutboundMessage_FileImportRequest request; setUp(() async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..fileImporterId = 1 ])); @@ -78,7 +78,7 @@ void main() { ..id = request.id ..fileUrl = "")); - await _expectImportError( + await _expectUseError( process, 'The file importer must return an absolute URL, was ""'); await process.close(); }); @@ -89,7 +89,7 @@ void main() { ..id = request.id ..fileUrl = "foo")); - await _expectImportError(process, + await _expectUseError(process, 'The file importer must return an absolute URL, was "foo"'); await process.close(); }); @@ -100,7 +100,7 @@ void main() { ..id = request.id ..fileUrl = "other:foo")); - await _expectImportError(process, + await _expectUseError(process, 'The file importer must return a file: URL, was "other:foo"'); await process.close(); }); @@ -112,8 +112,7 @@ void main() { var importerId = 5679; late OutboundMessage_FileImportRequest request; setUp(() async { - process.send( - compileString("@import 'other'", id: compilationId, importers: [ + process.send(compileString("@use 'other'", id: compilationId, importers: [ InboundMessage_CompileRequest_Importer()..fileImporterId = importerId ])); request = await getFileImportRequest(process); @@ -130,13 +129,13 @@ void main() { }); test("whether the import came from an @import", () async { - expect(request.fromImport, isTrue); + expect(request.fromImport, isFalse); await process.kill(); }); }); test("errors cause compilation to fail", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..fileImporterId = 1 ])); @@ -148,13 +147,13 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals('oh no')); - expect(failure.span.text, equals("'other'")); - expect(failure.stackTrace, equals('- 1:9 root stylesheet\n')); + expect(failure.span.text, equals("@use 'other'")); + expect(failure.stackTrace, equals('- 1:1 root stylesheet\n')); await process.close(); }); test("null results count as not found", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..fileImporterId = 1 ])); @@ -165,13 +164,13 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals("Can't find stylesheet to import.")); - expect(failure.span.text, equals("'other'")); + expect(failure.span.text, equals("@use 'other'")); await process.close(); }); group("attempts importers in order", () { test("with multiple file importers", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ for (var i = 0; i < 10; i++) InboundMessage_CompileRequest_Importer()..fileImporterId = i ])); @@ -188,7 +187,7 @@ void main() { }); test("with a mixture of file and normal importers", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ for (var i = 0; i < 10; i++) if (i % 2 == 0) InboundMessage_CompileRequest_Importer()..fileImporterId = i @@ -218,9 +217,9 @@ void main() { test("tries resolved URL as a relative path first", () async { await d.file("upstream.scss", "a {b: c}").create(); - await d.file("midstream.scss", "@import 'upstream';").create(); + await d.file("midstream.scss", "@use 'upstream';").create(); - process.send(compileString("@import 'midstream'", importers: [ + process.send(compileString("@use 'midstream'", importers: [ for (var i = 0; i < 10; i++) InboundMessage_CompileRequest_Importer()..fileImporterId = i ])); @@ -251,7 +250,7 @@ void main() { }); test("without a base URL", () async { - process.send(compileString("@import 'other'", + process.send(compileString("@use 'other'", importer: InboundMessage_CompileRequest_Importer() ..fileImporterId = 1)); @@ -268,7 +267,7 @@ void main() { }); test("with a base URL", () async { - process.send(compileString("@import 'other'", + process.send(compileString("@use 'other'", url: p.toUri(d.path("input")).toString(), importer: InboundMessage_CompileRequest_Importer() ..fileImporterId = 1)); @@ -281,8 +280,8 @@ void main() { /// Asserts that [process] emits a [CompileFailure] result with the given /// [message] on its protobuf stream and causes the compilation to fail. -Future _expectImportError(EmbeddedProcess process, Object message) async { +Future _expectUseError(EmbeddedProcess process, Object message) async { var failure = await getCompileFailure(process); expect(failure.message, equals(message)); - expect(failure.span.text, equals("'other'")); + expect(failure.span.text, equals("@use 'other'")); } diff --git a/test/embedded/function_test.dart b/test/embedded/function_test.dart index ceb6ec929..694341405 100644 --- a/test/embedded/function_test.dart +++ b/test/embedded/function_test.dart @@ -210,7 +210,7 @@ void main() { @use "sass:math"; @use "sass:meta"; - a {b: call(foo(meta.get-function("abs", $module: "math")), -1)} + a {b: meta.call(foo(meta.get-function("abs", $module: "math")), -1)} """, functions: [r"foo($arg)"])); var request = await getFunctionCallRequest(_process); @@ -226,8 +226,11 @@ void main() { }); test("defined in the host", () async { - _process.send( - compileString("a {b: call(foo(), true)}", functions: [r"foo()"])); + _process.send(compileString(""" + @use "sass:meta"; + + a {b: meta.call(foo(), true)} + """, functions: [r"foo()"])); var hostFunctionId = 5678; var request = await getFunctionCallRequest(_process); @@ -254,9 +257,11 @@ void main() { test("defined in the host and passed to and from the host", () async { _process.send(compileString(r""" + @use "sass:meta"; + $function: get-host-function(); $function: round-trip($function); - a {b: call($function, true)} + a {b: meta.call($function, true)} """, functions: [r"get-host-function()", r"round-trip($function)"])); var hostFunctionId = 5678; @@ -311,7 +316,7 @@ void main() { group("unquoted", () { test("and empty", () async { - var value = (await _protofy('unquote("")')).string; + var value = (await _protofy('string.unquote("")')).string; expect(value.text, isEmpty); expect(value.quoted, isFalse); }); @@ -1750,8 +1755,9 @@ void main() { group("reports a compilation error for a function with a signature", () { Future expectSignatureError( String signature, Object message) async { - _process.send( - compileString("a {b: inspect(foo())}", functions: [r"foo()"])); + _process.send(compileString( + "@use 'sass:meta';\na {b: meta.inspect(foo())}", + functions: [r"foo()"])); var request = await getFunctionCallRequest(_process); expect(request.arguments, isEmpty); @@ -1805,6 +1811,7 @@ Future _protofy(String sassScript) async { @use 'sass:map'; @use 'sass:math'; @use 'sass:meta'; +@use 'sass:string'; @function capture-args(\$args...) { \$_: meta.keywords(\$args); @@ -1838,7 +1845,9 @@ void _testSerializationAndRoundTrip(Value value, String expected, /// `meta.inspect()` function. Future _deprotofy(Value value, {bool inspect = false}) async { _process.send(compileString( - inspect ? "a {b: inspect(foo())}" : "a {b: foo()}", + inspect + ? "@use 'sass:meta';\na {b: meta.inspect(foo())}" + : "a {b: foo()}", functions: [r"foo()"])); var request = await getFunctionCallRequest(_process); diff --git a/test/embedded/importer_test.dart b/test/embedded/importer_test.dart index 2eb1b1efd..ee4d90c0f 100644 --- a/test/embedded/importer_test.dart +++ b/test/embedded/importer_test.dart @@ -23,7 +23,7 @@ void main() { group("emits a protocol error", () { test("for a response without a corresponding request ID", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -41,7 +41,7 @@ void main() { }); test("for a response that doesn't match the request type", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -110,7 +110,7 @@ void main() { group("canonicalization", () { group("emits a compile failure", () { test("for a canonicalize response with an empty URL", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -126,7 +126,7 @@ void main() { }); test("for a canonicalize response with a relative URL", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -146,7 +146,7 @@ void main() { var importerId = 5679; late OutboundMessage_CanonicalizeRequest request; setUp(() async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = importerId ])); request = await getCanonicalizeRequest(process); @@ -164,7 +164,7 @@ void main() { }); test("errors cause compilation to fail", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -176,13 +176,13 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals('oh no')); - expect(failure.span.text, equals("'other'")); - expect(failure.stackTrace, equals('- 1:9 root stylesheet\n')); + expect(failure.span.text, equals("@use 'other'")); + expect(failure.stackTrace, equals('- 1:1 root stylesheet\n')); await process.close(); }); test("null results count as not found", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -193,13 +193,13 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals("Can't find stylesheet to import.")); - expect(failure.span.text, equals("'other'")); + expect(failure.span.text, equals("@use 'other'")); await process.close(); }); group("the containing URL", () { test("is unset for a potentially canonical scheme", () async { - process.send(compileString('@import "u:orange"', importers: [ + process.send(compileString('@use "u:orange"', importers: [ InboundMessage_CompileRequest_Importer(importerId: 1) ])); @@ -210,7 +210,7 @@ void main() { group("for a non-canonical scheme", () { test("is set to the original URL", () async { - process.send(compileString('@import "u:orange"', + process.send(compileString('@use "u:orange"', importers: [ InboundMessage_CompileRequest_Importer( importerId: 1, nonCanonicalScheme: ["u"]) @@ -223,7 +223,7 @@ void main() { }); test("is unset to the original URL is unset", () async { - process.send(compileString('@import "u:orange"', importers: [ + process.send(compileString('@use "u:orange"', importers: [ InboundMessage_CompileRequest_Importer( importerId: 1, nonCanonicalScheme: ["u"]) ])); @@ -236,7 +236,7 @@ void main() { group("for a schemeless load", () { test("is set to the original URL", () async { - process.send(compileString('@import "orange"', + process.send(compileString('@use "orange"', importers: [ InboundMessage_CompileRequest_Importer(importerId: 1) ], @@ -248,7 +248,7 @@ void main() { }); test("is unset to the original URL is unset", () async { - process.send(compileString('@import "u:orange"', importers: [ + process.send(compileString('@use "u:orange"', importers: [ InboundMessage_CompileRequest_Importer(importerId: 1) ])); @@ -262,7 +262,7 @@ void main() { test( "fails if the importer returns a canonical URL with a non-canonical " "scheme", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer( importerId: 1, nonCanonicalScheme: ["u"]) ])); @@ -278,7 +278,7 @@ void main() { }); test("attempts importers in order", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ for (var i = 0; i < 10; i++) InboundMessage_CompileRequest_Importer()..importerId = i ])); @@ -295,7 +295,7 @@ void main() { }); test("tries resolved URL using the original importer first", () async { - process.send(compileString("@import 'midstream'", importers: [ + process.send(compileString("@use 'midstream'", importers: [ for (var i = 0; i < 10; i++) InboundMessage_CompileRequest_Importer()..importerId = i ])); @@ -321,7 +321,7 @@ void main() { ..importResponse = (InboundMessage_ImportResponse() ..id = import.id ..success = (InboundMessage_ImportResponse_ImportSuccess() - ..contents = "@import 'upstream'"))); + ..contents = "@use 'upstream'"))); canonicalize = await getCanonicalizeRequest(process); expect(canonicalize.importerId, equals(5)); @@ -334,7 +334,7 @@ void main() { group("importing", () { group("emits a compile failure", () { test("for an import result with a relative sourceMapUrl", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await _canonicalize(process); @@ -356,7 +356,7 @@ void main() { var importerId = 5678; late OutboundMessage_ImportRequest request; setUp(() async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = importerId ])); @@ -381,7 +381,7 @@ void main() { }); test("null results count as not found", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -398,12 +398,12 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals("Can't find stylesheet to import.")); - expect(failure.span.text, equals("'other'")); + expect(failure.span.text, equals("@use 'other'")); await process.close(); }); test("errors cause compilation to fail", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await _canonicalize(process); @@ -416,13 +416,13 @@ void main() { var failure = await getCompileFailure(process); expect(failure.message, equals('oh no')); - expect(failure.span.text, equals("'other'")); - expect(failure.stackTrace, equals('- 1:9 root stylesheet\n')); + expect(failure.span.text, equals("@use 'other'")); + expect(failure.stackTrace, equals('- 1:1 root stylesheet\n')); await process.close(); }); test("can return an SCSS file", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await _canonicalize(process); @@ -439,7 +439,7 @@ void main() { }); test("can return an indented syntax file", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await _canonicalize(process); @@ -457,7 +457,7 @@ void main() { }); test("can return a plain CSS file", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await _canonicalize(process); @@ -475,11 +475,9 @@ void main() { }); test("uses a data: URL rather than an empty source map URL", () async { - process.send(compileString("@import 'other'", - sourceMap: true, - importers: [ - InboundMessage_CompileRequest_Importer()..importerId = 1 - ])); + process.send(compileString("@use 'other'", sourceMap: true, importers: [ + InboundMessage_CompileRequest_Importer()..importerId = 1 + ])); await _canonicalize(process); var request = await getImportRequest(process); @@ -498,11 +496,9 @@ void main() { }); test("uses a non-empty source map URL", () async { - process.send(compileString("@import 'other'", - sourceMap: true, - importers: [ - InboundMessage_CompileRequest_Importer()..importerId = 1 - ])); + process.send(compileString("@use 'other'", sourceMap: true, importers: [ + InboundMessage_CompileRequest_Importer()..importerId = 1 + ])); await _canonicalize(process); var request = await getImportRequest(process); @@ -522,7 +518,7 @@ void main() { }); test("handles an importer for a string compile request", () async { - process.send(compileString("@import 'other'", + process.send(compileString("@use 'other'", importer: InboundMessage_CompileRequest_Importer()..importerId = 1)); await _canonicalize(process); @@ -541,7 +537,7 @@ void main() { test("are used to load imports", () async { await d.dir("dir", [d.file("other.scss", "a {b: c}")]).create(); - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..path = d.path("dir") ])); @@ -554,7 +550,7 @@ void main() { await d.dir("dir$i", [d.file("other$i.scss", "a {b: $i}")]).create(); } - process.send(compileString("@import 'other2'", importers: [ + process.send(compileString("@use 'other2'", importers: [ for (var i = 0; i < 3; i++) InboundMessage_CompileRequest_Importer()..path = d.path("dir$i") ])); @@ -566,7 +562,7 @@ void main() { test("take precedence over later importers", () async { await d.dir("dir", [d.file("other.scss", "a {b: c}")]).create(); - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..path = d.path("dir"), InboundMessage_CompileRequest_Importer()..importerId = 1 ])); @@ -578,7 +574,7 @@ void main() { test("yield precedence to earlier importers", () async { await d.dir("dir", [d.file("other.scss", "a {b: c}")]).create(); - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1, InboundMessage_CompileRequest_Importer()..path = d.path("dir") ])); @@ -654,5 +650,5 @@ Future _canonicalize(EmbeddedProcess process) async { Future _expectImportError(EmbeddedProcess process, Object message) async { var failure = await getCompileFailure(process); expect(failure.message, equals(message)); - expect(failure.span.text, equals("'other'")); + expect(failure.span.text, equals("@use 'other'")); } diff --git a/test/embedded/protocol_test.dart b/test/embedded/protocol_test.dart index b1ffdee97..1744f754e 100644 --- a/test/embedded/protocol_test.dart +++ b/test/embedded/protocol_test.dart @@ -68,7 +68,7 @@ void main() { }); test("caused by duplicate compilation IDs", () async { - process.send(compileString("@import 'other'", importers: [ + process.send(compileString("@use 'other'", importers: [ InboundMessage_CompileRequest_Importer()..importerId = 1 ])); await getCanonicalizeRequest(process);