Skip to content

Commit e47850a

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[CFE] Reproduce issue 47176
This CL reproduces - but does not fix - issue #47176 (#47176) Change-Id: I03384a6933a6f8181e909d8b6bc812e5550f903f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213261 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 7d467e8 commit e47850a

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

pkg/front_end/test/incremental_suite.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import 'package:front_end/src/api_prototype/experimental_flags.dart'
2626
show ExperimentalFlag, experimentEnabledVersion;
2727

2828
import "package:front_end/src/api_prototype/memory_file_system.dart"
29-
show MemoryFileSystem;
29+
show MemoryFileSystem, MemoryFileSystemEntity;
3030

3131
import 'package:front_end/src/base/nnbd_mode.dart' show NnbdMode;
3232

@@ -308,7 +308,7 @@ Future<Map<String, List<int>>> createModules(
308308
final Uri base = Uri.parse("org-dartlang-test:///");
309309
final Uri sdkSummaryUri = base.resolve(sdkSummary);
310310

311-
MemoryFileSystem fs = new MemoryFileSystem(base);
311+
TestMemoryFileSystem fs = new TestMemoryFileSystem(base);
312312
fs.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
313313

314314
// Setup all sources
@@ -508,7 +508,7 @@ class NewWorldTest {
508508
}
509509

510510
if (brandNewWorld) {
511-
fs = new MemoryFileSystem(base);
511+
fs = new TestMemoryFileSystem(base);
512512
}
513513
fs!.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
514514
bool expectInitializeFromDill = false;
@@ -1991,3 +1991,19 @@ void doSimulateTransformer(Component c) {
19911991
}
19921992
}
19931993
}
1994+
1995+
class TestMemoryFileSystem extends MemoryFileSystem {
1996+
TestMemoryFileSystem(Uri currentDirectory) : super(currentDirectory);
1997+
1998+
@override
1999+
MemoryFileSystemEntity entityForUri(Uri uri) {
2000+
// Try to "sanitize" the uri as a real file system does, namely
2001+
// "a/b.dart" and "a//b.dart" returns the same file.
2002+
if (uri.pathSegments.contains("")) {
2003+
Uri newUri = uri.replace(
2004+
pathSegments: uri.pathSegments.where((element) => element != ""));
2005+
return super.entityForUri(newUri);
2006+
}
2007+
return super.entityForUri(uri);
2008+
}
2009+
}

pkg/front_end/test/spell_checking_list_tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ rows
825825
runtimes
826826
rv
827827
sandboxed
828+
sanitize
828829
saves
829830
scans
830831
scheduler

pkg/front_end/testcases/incremental.status

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66

77
# http://dartbug.com/41812#issuecomment-684825703
88
#strongmode_mixins_2: Crash
9+
10+
changing_modules_16: Crash
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright (c) 2021, 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.md file.
4+
5+
# Reproduction of https://github.com/dart-lang/sdk/issues/47176
6+
# Compile an application with modules where one module has imported another
7+
# module with too many slashes. Now try to import it correctly.
8+
# This is essentially equivalent to not loading a needed component.
9+
10+
type: newworld
11+
target: DDC
12+
modules:
13+
moduleA:
14+
moduleA/x/lib.dart: |
15+
void foo() { }
16+
moduleA/.packages: |
17+
moduleA:.
18+
moduleB:
19+
moduleB/x/lib.dart: |
20+
// Mind the double-slash! (on Windows this could probably also be a change
21+
// in case (e.g 'lib' vs 'Lib')).
22+
import 'package:moduleA/x//lib.dart';
23+
void bar() { }
24+
moduleB/.packages: |
25+
moduleA:../moduleA
26+
moduleB:.
27+
worlds:
28+
- entry: main.dart
29+
fromComponent: true
30+
sources:
31+
main.dart: |
32+
import 'package:moduleB/x/lib.dart';
33+
main() {
34+
bar();
35+
}
36+
.packages: |
37+
moduleA:moduleA
38+
moduleB:moduleB
39+
modules:
40+
- moduleA
41+
- moduleB
42+
expectedLibraryCount: 3
43+
neededDillLibraries:
44+
- package:module/x/lib.dart
45+
expectedContent:
46+
org-dartlang-test:///main.dart:
47+
- Procedure main
48+
package:module/lib.dart:
49+
- Procedure foo

0 commit comments

Comments
 (0)