mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 05:47:14 +00:00
f48b8c6908
Also adds support for modular tests with precompiled macros, and one test exercising that. Change-Id: Ie372ea7fcb270ecd55baa54c4ed1c4ae5a527df4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361261 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com> Auto-Submit: Jake Macdonald <jakemac@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
86 lines
3.3 KiB
Dart
86 lines
3.3 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// Unit test for validation of modular steps in a pipeline.
|
|
library;
|
|
|
|
import 'package:test/test.dart';
|
|
import 'package:modular_test/src/suite.dart';
|
|
|
|
main() {
|
|
test('module test is not empty', () {
|
|
var m = Module("a", [], Uri.parse("app:/"), [], {});
|
|
expect(() => ModularTest([], m, []), throwsA(TypeMatcher<ArgumentError>()));
|
|
});
|
|
|
|
test('package must depend on package', () {
|
|
var m1a = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isPackage: false);
|
|
var m1b = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isPackage: true);
|
|
|
|
var m2a = Module("b", [m1a], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isPackage: true);
|
|
var m2b = Module("b", [m1b], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isPackage: true);
|
|
expect(() => ModularTest([m1a, m2a], m2a, []),
|
|
throwsA(TypeMatcher<InvalidModularTestError>()));
|
|
expect(ModularTest([m1b, m2b], m2b, []), isNotNull);
|
|
});
|
|
|
|
test('shared module must depend on shared modules', () {
|
|
var m1a = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isShared: false);
|
|
var m1b = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isShared: true);
|
|
|
|
var m2a = Module("b", [m1a], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isShared: true);
|
|
var m2b = Module("b", [m1b], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isShared: true);
|
|
expect(() => ModularTest([m1a, m2a], m2a, []),
|
|
throwsA(TypeMatcher<InvalidModularTestError>()));
|
|
expect(ModularTest([m1b, m2b], m2b, []), isNotNull);
|
|
});
|
|
|
|
test('sdk module must not have dependencies', () {
|
|
var m1a = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isSdk: false);
|
|
var m1b = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isSdk: true);
|
|
|
|
var m2a = Module("b", [m1a], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isSdk: true);
|
|
var m2b = Module("b", [m1b], Uri.parse("app:/"),
|
|
[Uri.parse("b/b1.dart"), Uri.parse("b/b2.dart")], {},
|
|
isSdk: true);
|
|
expect(() => ModularTest([m1a, m2a], m2a, []),
|
|
throwsA(TypeMatcher<InvalidModularTestError>()));
|
|
expect(() => ModularTest([m1b, m2b], m2b, []),
|
|
throwsA(TypeMatcher<InvalidModularTestError>()));
|
|
});
|
|
|
|
test('sdk module cannot be package module', () {
|
|
var m = Module("a", const [], Uri.parse("app:/"),
|
|
[Uri.parse("a1.dart"), Uri.parse("a2.dart")], {},
|
|
isSdk: true);
|
|
expect(ModularTest([m], m, []), isNotNull);
|
|
|
|
m.isPackage = true;
|
|
expect(() => ModularTest([m], m, []),
|
|
throwsA(TypeMatcher<InvalidModularTestError>()));
|
|
});
|
|
}
|