Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 96c2d3c

Browse files
vsmenoncommit-bot@chromium.org
authored andcommitted
[dartdevc] enable testing of ddc internals
Change-Id: I8f4753a9a1f2f9f61df0d045adf07ff75fe32907 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103820 Reviewed-by: Alexander Thomas <[email protected]> Commit-Queue: Vijay Menon <[email protected]>
1 parent 554f9db commit 96c2d3c

File tree

6 files changed

+57
-7
lines changed

6 files changed

+57
-7
lines changed

pkg/dev_compiler/lib/src/analyzer/code_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class CodeGenerator extends Object
428428
String jsLibraryName(LibraryElement library) {
429429
var uri = library.source.uri;
430430
if (uri.scheme == 'dart') {
431-
return uri.path;
431+
return isSdkInternalRuntime(library) ? 'dart' : uri.path;
432432
}
433433
// TODO(vsm): This is not necessarily unique if '__' appears in a file name.
434434
var encodedSeparator = '__';

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ class ProgramCompiler extends Object
317317
@override
318318
String jsLibraryName(Library library) {
319319
var uri = library.importUri;
320-
if (uri.scheme == 'dart') return uri.path;
320+
if (uri.scheme == 'dart') {
321+
return isSdkInternalRuntime(library) ? 'dart' : uri.path;
322+
}
321323

322324
// TODO(vsm): This is not necessarily unique if '__' appears in a file name.
323325
Iterable<String> segments;

pkg/dev_compiler/lib/src/kernel/target.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,21 @@ class DevCompilerTarget extends Target {
6767
uri.scheme == 'dart' &&
6868
(uri.path == 'core' || uri.path == '_interceptors');
6969

70+
bool _allowedTestLibrary(Uri uri) {
71+
String scriptName = uri.path;
72+
return scriptName.contains('tests/compiler/dartdevc_native');
73+
}
74+
75+
bool _allowedDartLibrary(Uri uri) => uri.scheme == 'dart';
76+
77+
@override
78+
bool enableNative(Uri uri) =>
79+
_allowedTestLibrary(uri) || _allowedDartLibrary(uri);
80+
7081
@override
71-
bool enableNative(Uri uri) => uri.scheme == 'dart';
82+
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
83+
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
84+
_allowedTestLibrary(importer);
7285

7386
@override
7487
bool get nativeExtensionExpectsString => false;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2019, 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+
import "package:expect/expect.dart";
6+
import 'dart:_foreign_helper' show JS;
7+
import 'dart:_runtime' as dart;
8+
9+
void main() {
10+
var data = JS('', '[1, 2, 3, 4]');
11+
Expect.isFalse(data is List<int>);
12+
13+
var list = dart.constList(data, dart.unwrapType(int));
14+
Expect.isTrue(list is List<int>);
15+
Expect.throws(() {
16+
list[0] = 0;
17+
});
18+
19+
var set = dart.constSet<int>(data);
20+
Expect.isTrue(set is Set<int>);
21+
Expect.isTrue(set.contains(3));
22+
Expect.throws(() => set.clear());
23+
24+
var map = dart.constMap<int, int>(data);
25+
Expect.isTrue(map is Map<int, int>);
26+
Expect.equals(map[1], 2);
27+
Expect.throws(() {
28+
map[1] = 42;
29+
});
30+
}

tools/bots/test_matrix.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,8 @@
868868
"-ndartdevc-checked-${system}-release-chrome",
869869
"language_2",
870870
"corelib_2",
871-
"lib_2"
871+
"lib_2",
872+
"dartdevc_native"
872873
]
873874
},
874875
{
@@ -877,7 +878,8 @@
877878
"-ndartdevk-checked-${system}-release-chrome",
878879
"language_2",
879880
"corelib_2",
880-
"lib_2"
881+
"lib_2",
882+
"dartdevc_native"
881883
]
882884
},
883885
{
@@ -962,7 +964,8 @@
962964
"-ndartdevc-checked-mac-release-chrome",
963965
"language_2",
964966
"corelib_2",
965-
"lib_2"
967+
"lib_2",
968+
"dartdevc_native"
966969
]
967970
},
968971
{
@@ -971,7 +974,8 @@
971974
"-ndartdevk-checked-mac-release-chrome",
972975
"language_2",
973976
"corelib_2",
974-
"lib_2"
977+
"lib_2",
978+
"dartdevc_native"
975979
]
976980
},
977981
{

tools/testing/dart/test_configurations.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final TEST_SUITE_DIRECTORIES = [
3535
new Path('tests/compiler/dart2js'),
3636
new Path('tests/compiler/dart2js_extra'),
3737
new Path('tests/compiler/dart2js_native'),
38+
new Path('tests/compiler/dartdevc_native'),
3839
new Path('tests/corelib_2'),
3940
new Path('tests/kernel'),
4041
new Path('tests/language_2'),

0 commit comments

Comments
 (0)