Skip to content

Commit b453c6b

Browse files
aamCommit Bot
authored andcommitted
[gardening] Fix env_test/has_mirror_support.
Fix the test so it reports that mirrors are not supported in aot configuration. Fixes #48125 Change-Id: I07fceebf8cbee8048988c8bd5287c8aec1bb8f0e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227582 Reviewed-by: Lasse Nielsen <lrn@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
1 parent 38f013d commit b453c6b

File tree

8 files changed

+81
-28
lines changed

8 files changed

+81
-28
lines changed

pkg/expect/lib/config.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// Access to the runner configuration this test is running in.
6+
///
7+
/// Provides queries against and properties of the current configuration
8+
/// that a test is being compiled and executed in.
9+
///
10+
/// This library is separate from `expect.dart` because it uses
11+
/// `fromEnvironment` constants that cannot be precompiled,
12+
/// and we precompile `expect.dart`.
13+
14+
library expect_config;
15+
16+
import 'package:smith/smith.dart';
17+
18+
final Configuration _configuration = Configuration.parse(
19+
const String.fromEnvironment("test_runner.configuration"),
20+
<String, dynamic>{});
21+
22+
bool get isDart2jsConfiguration {
23+
return _configuration.compiler == Compiler.dart2js;
24+
}
25+
26+
bool get isDdcConfiguration {
27+
return _configuration.compiler == Compiler.dartdevk ||
28+
_configuration.compiler == Compiler.dartdevc;
29+
}
30+
31+
bool get isVmAotConfiguration {
32+
return _configuration.compiler == Compiler.dartkp;
33+
}

pkg/expect/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ environment:
1313

1414
dependencies:
1515
meta: any
16+
smith: any
1617

1718
dependency_overrides:
1819
meta:
1920
path: ../meta
21+
smith:
22+
path: ../smith

pkg/modular_test/lib/src/loader.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ _detectCyclesAndRemoveUnreachable(Map<String, Module> modules, Module main) {
252252
/// Default entries for a .packages file with paths relative to the SDK root.
253253
List<int> _defaultPackagesInput = utf8.encode('''
254254
expect:pkg/expect/lib
255+
smith:pkg/smith/lib
255256
async_helper:pkg/async_helper/lib
256257
meta:pkg/meta/lib
257258
collection:third_party/pkg/collection/lib
@@ -264,7 +265,8 @@ collection:third_party/pkg/collection/lib
264265
// import graph, or adding tests that validate this is always up to date.
265266
String _defaultPackagesSpec = '''
266267
dependencies:
267-
expect: meta
268+
expect: [meta, smith]
269+
smith: []
268270
meta: []
269271
async_helper: []
270272
collection: []

pkg/modular_test/test/loader/default_package_dependency_error/expectation.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ expect
44
is package? yes
55
is shared? yes
66
is sdk? no
7-
dependencies: meta, sdk
7+
dependencies: meta, smith, sdk
8+
lib/config.dart
89
lib/expect.dart
910
lib/minitest.dart
1011

@@ -31,3 +32,13 @@ sdk
3132
is sdk? yes
3233
(no dependencies)
3334
(sdk sources omitted)
35+
36+
smith
37+
is package? yes
38+
is shared? yes
39+
is sdk? no
40+
dependencies: sdk
41+
lib/builder.dart
42+
lib/configuration.dart
43+
lib/smith.dart
44+
lib/test_matrix.dart

pkg/modular_test/test/loader/valid_packages/expectation.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ expect
44
is package? yes
55
is shared? yes
66
is sdk? no
7-
dependencies: meta, sdk
7+
dependencies: meta, smith, sdk
8+
lib/config.dart
89
lib/expect.dart
910
lib/minitest.dart
1011

@@ -40,3 +41,13 @@ sdk
4041
is sdk? yes
4142
(no dependencies)
4243
(sdk sources omitted)
44+
45+
smith
46+
is package? yes
47+
is shared? yes
48+
is sdk? no
49+
dependencies: sdk
50+
lib/builder.dart
51+
lib/configuration.dart
52+
lib/smith.dart
53+
lib/test_matrix.dart

pkg/test_runner/lib/src/options.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,10 @@ has been specified on the command line.''',
778778
data['test_server_cross_origin_port'] as int,
779779
testDriverErrorPort: data["test_driver_error_port"] as int,
780780
localIP: data["local_ip"] as String,
781-
sharedOptions: sharedOptions,
781+
sharedOptions: <String>[
782+
...sharedOptions,
783+
"-Dtest_runner.configuration=${innerConfiguration.name}"
784+
],
782785
packages: data["packages"] as String,
783786
serviceResponseSizesDirectory:
784787
data['service_response_sizes_directory'] as String,

tests/language/library/env_test.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:expect/expect.dart';
6+
import 'package:expect/config.dart';
67

78
main() {
89
const NOT_PRESENT = false;
@@ -61,18 +62,12 @@ main() {
6162
const bool.fromEnvironment("dart.library.io", defaultValue: false));
6263
}
6364

64-
bool? hasMirrorSupport;
65-
hasMirrorSupport = true; //# has_mirror_support: ok
66-
hasMirrorSupport = false; //# has_no_mirror_support: ok
67-
68-
if (hasMirrorSupport != null) {
69-
bool expectedResult = hasMirrorSupport ? true : NOT_PRESENT;
70-
71-
Expect.equals(
72-
expectedResult,
73-
const bool.fromEnvironment("dart.library.mirrors",
74-
defaultValue: NOT_PRESENT));
75-
}
65+
bool hasMirrorSupport = !isDart2jsConfiguration &&
66+
!isDdcConfiguration && !isVmAotConfiguration;
67+
Expect.equals(
68+
hasMirrorSupport,
69+
const bool.fromEnvironment("dart.library.mirrors",
70+
defaultValue: NOT_PRESENT));
7671

7772
Expect.equals(
7873
NOT_PRESENT,

tests/language_2/library/env_test.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// @dart = 2.9
66

77
import 'package:expect/expect.dart';
8+
import 'package:expect/config.dart';
89

910
main() {
1011
const NOT_PRESENT = false;
@@ -63,18 +64,12 @@ main() {
6364
const bool.fromEnvironment("dart.library.io", defaultValue: false));
6465
}
6566

66-
bool hasMirrorSupport;
67-
hasMirrorSupport = true; //# has_mirror_support: ok
68-
hasMirrorSupport = false; //# has_no_mirror_support: ok
69-
70-
if (hasMirrorSupport != null) {
71-
bool expectedResult = hasMirrorSupport ? true : NOT_PRESENT;
72-
73-
Expect.equals(
74-
expectedResult,
75-
const bool.fromEnvironment("dart.library.mirrors",
76-
defaultValue: NOT_PRESENT));
77-
}
67+
bool hasMirrorSupport = !isDart2jsConfiguration &&
68+
!isDdcConfiguration && !isVmAotConfiguration;
69+
Expect.equals(
70+
hasMirrorSupport,
71+
const bool.fromEnvironment("dart.library.mirrors",
72+
defaultValue: NOT_PRESENT));
7873

7974
Expect.equals(
8075
NOT_PRESENT,

0 commit comments

Comments
 (0)