mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
8fa8d1f1f1
Change-Id: If3228bf1fbd24837272336c09c4c8b1693670222 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250782 Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
44 lines
1.7 KiB
Dart
44 lines
1.7 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
import 'package:build_integration/file_system/single_root.dart';
|
|
import 'package:front_end/src/api_unstable/build_integration.dart';
|
|
import 'package:front_end/src/api_prototype/memory_file_system.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
main() {
|
|
var root = Uri.parse('org-dartlang-test:///');
|
|
var fileSystem = SingleRootFileSystem(
|
|
'single-root', root.resolve('A/B'), MemoryFileSystem(root));
|
|
|
|
SingleRootFileSystemEntity entityOf(String uri) =>
|
|
fileSystem.entityForUri(Uri.parse(uri)) as SingleRootFileSystemEntity;
|
|
|
|
String effectiveUriOf(String uri) => '${entityOf(uri).delegate.uri}';
|
|
|
|
test('root is normalized', () {
|
|
expect(fileSystem.root.path, '/A/B/');
|
|
});
|
|
|
|
test('URIs with the marker scheme are converted', () {
|
|
expect(effectiveUriOf('single-root:///a/b/1.dart'),
|
|
'org-dartlang-test:///A/B/a/b/1.dart');
|
|
});
|
|
|
|
test('single-root expects absolute paths', () {
|
|
expect(effectiveUriOf('single-root:///a/8.dart'),
|
|
'org-dartlang-test:///A/B/a/8.dart');
|
|
expect(effectiveUriOf('single-root:///../B/a/8.dart'),
|
|
'org-dartlang-test:///A/B/B/a/8.dart');
|
|
});
|
|
|
|
test('URIs with other schemes are not supported', () {
|
|
expect(() => entityOf('foo-root:///a/b/1.dart'),
|
|
throwsA((e) => e is FileSystemException));
|
|
|
|
// The scheme of the underlying file system is also not supported
|
|
expect(() => entityOf('org-dartlang-test:///a/b/1.dart'),
|
|
throwsA((e) => e is FileSystemException));
|
|
});
|
|
}
|