From 1c7c5df0801ef578d6650f61392102e42e3fbff6 Mon Sep 17 00:00:00 2001 From: Tien Do Nam Date: Sat, 7 Dec 2024 03:41:34 +0100 Subject: [PATCH] test: enable compilation test --- slang/pubspec.yaml | 2 +- .../integration/main/compilation_test.dart | 30 +++++-------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/slang/pubspec.yaml b/slang/pubspec.yaml index c2dbcba..926f15a 100644 --- a/slang/pubspec.yaml +++ b/slang/pubspec.yaml @@ -25,6 +25,6 @@ dependencies: yaml: ^3.1.0 dev_dependencies: - expect_error: ^1.0.7 + analyzer: '>=6.0.0' lints: any test: ^1.21.0 diff --git a/slang/test/integration/main/compilation_test.dart b/slang/test/integration/main/compilation_test.dart index c6378e6..8d50cb6 100644 --- a/slang/test/integration/main/compilation_test.dart +++ b/slang/test/integration/main/compilation_test.dart @@ -1,28 +1,18 @@ -@Skip('not updated for multiple files') -library; - -import 'package:expect_error/expect_error.dart'; +import 'package:analyzer/dart/analysis/utilities.dart'; import 'package:test/test.dart'; import '../../util/resources_utils.dart'; /// These tests ensure that the generated code compiles. +/// It currently only checks for syntax errors. void main() { - late Library library; - - setUp(() async { - // A workaround so we have Flutter available in the analyzer. - // See: https://pub.dev/packages/expect_error#flutter-support - library = await Library.custom( - packageName: 'slang_flutter', - path: 'not used', - packageRoot: '../slang_flutter', - ); - }); - - Future expectCompiles(String path) { + void expectCompiles(String path) { final output = loadResource(path); - return expectLater(library.withCode(output), compiles); + final result = parseString( + path: 'path.dart', + content: output, + ); + expect(result.errors, isEmpty); } test('fallback base locale', () { @@ -41,10 +31,6 @@ void main() { expectCompiles('main/_expected_rich_text.output'); }); - test('single output', () { - expectCompiles('main/_expected_single.output'); - }); - test('translation overrides', () { expectCompiles('main/_expected_translation_overrides.output'); });