diff --git a/generator/lib/src/session.dart b/generator/lib/src/session.dart index 900cb4a72d..d0d7129b43 100644 --- a/generator/lib/src/session.dart +++ b/generator/lib/src/session.dart @@ -27,7 +27,7 @@ const _sessionKey = #SessionKey; // in case multiple libs are processed concurrently, we make session zone local Session get session => Zone.current[_sessionKey] as Session; -Future scopeSession( +FutureOr scopeSession( ResolvedLibraryResult resolvedLibrary, FutureOr Function() fn, { String? prefix, diff --git a/generator/test/test_util.dart b/generator/test/test_util.dart index 8354ac04f6..7754e791e8 100644 --- a/generator/test/test_util.dart +++ b/generator/test/test_util.dart @@ -51,9 +51,18 @@ class GoldenFileMatcher extends Matcher { return _matcher.describe(description); } + @override + Description describeMismatch( + dynamic item, + Description mismatchDescription, + Map matchState, + bool verbose, + ) => + _matcher.describeMismatch(item, mismatchDescription, matchState, verbose); + @override bool matches(dynamic item, Map matchState) { - // create golden, if missing + // create golden master, if missing if (!golden.existsSync()) { var bytes = []; if (item is File) { @@ -72,19 +81,19 @@ class GoldenFileMatcher extends Matcher { /// A special equality matcher for strings. class LinesEqualsMatcher extends Matcher { - late final List expectedLines; + final String expected; - LinesEqualsMatcher(String expected) { - expectedLines = expected.split("\n"); - } + LinesEqualsMatcher(this.expected); @override - Description describe(Description description) => description.add("LinesEqualsMatcher"); + Description describe(Description description) => description.add(expected); @override // ignore: strict_raw_type bool matches(dynamic actual, Map matchState) { final actualValue = utf8.decode(actual as List); + + final expectedLines = expected.split("\n"); final actualLines = actualValue.split("\n"); if (actualLines.length > expectedLines.length) { @@ -109,6 +118,7 @@ class LinesEqualsMatcher extends Matcher { @override Description describeMismatch(dynamic item, Description mismatchDescription, Map matchState, bool verbose) { + mismatchDescription.addDescriptionOf(item).replace(utf8.decode(item as List)); if (matchState["Error"] != null) { mismatchDescription.add(matchState["Error"] as String); }