Skip to content

Commit

Permalink
test: enable compilation test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Dec 7, 2024
1 parent 81187d2 commit 1c7c5df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion slang/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 8 additions & 22 deletions slang/test/integration/main/compilation_test.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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', () {
Expand All @@ -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');
});
Expand Down

0 comments on commit 1c7c5df

Please sign in to comment.