flutter/packages/flutter_tools/test/dart_dependencies_test.dart
asiva aef9804784 Roll engine to version d80c1de7b53af81a0b4385eb3f13de1ef77f0d2d
Contains the following changes:

d80c1de7b (HEAD -> master, upstream/master) Roll src/third_party/skia ab3144c3abb9..656cefe65d62 (11 commits) (#6362)
edf6249e0 Add pushOffset to SceneBuilder (#6349)
3a01f3956 Change log level from ERROR to WARNING (#6361)
5ae470845 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (#6360)
763627fff Do not export libdart symbols (#6337)
3052dbd79 SystemNavigator.pop can pop w/o UINavigationController (#6341)
0c096f798 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (#6359)
b8c2a17a1 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (#6356)
c589b312a Expose push/popRoute on FlutterViewController (#6347)
075b3fcca Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (#6355)
2dd9b99aa Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (#6354)
5b799381f Dont make any binaries specify an X11 dependency. (#6353)
309ac4e1b V0.8.2 fix compile problem with xcode10 (#6339)
26fdd1e4f Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (#6351)
cc44ca5d0 Perform persistent cache stores on the IO thread outside the frame workload. (#6350)
f2a3df97e Wire up the Skia persistent GPU related artifacts cache. (#6278)
2018-09-27 15:17:03 -07:00

100 lines
4.0 KiB
Dart

// Copyright 2016 The Chromium Authors. 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:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'src/common.dart';
import 'src/context.dart';
void main() {
group('DartDependencySetBuilder', () {
final String dataPath = fs.path.join(
getFlutterRoot(),
'packages',
'flutter_tools',
'test',
'data',
'dart_dependencies_test',
);
testUsingContext('good', () {
final String testPath = fs.path.join(dataPath, 'good');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
DartDependencySetBuilder(mainPath, packagesPath);
final Set<String> dependencies = builder.build();
expect(dependencies.contains(canonicalizePath(mainPath)), isTrue);
expect(dependencies.contains(canonicalizePath(fs.path.join(testPath, 'foo.dart'))), isTrue);
});
testUsingContext('syntax_error', () {
final String testPath = fs.path.join(dataPath, 'syntax_error');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
DartDependencySetBuilder(mainPath, packagesPath);
try {
builder.build();
fail('expect an exception to be thrown.');
} on DartDependencyException catch (error) {
expect(error.toString(), contains('foo.dart: Expected a string literal'));
}
});
testUsingContext('bad_path', () {
final String testPath = fs.path.join(dataPath, 'bad_path');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
DartDependencySetBuilder(mainPath, packagesPath);
try {
builder.build();
fail('expect an exception to be thrown.');
} on DartDependencyException catch (error) {
expect(error.toString(), contains('amaze${fs.path.separator}and${fs.path.separator}astonish.dart'));
}
});
testUsingContext('bad_package', () {
final String testPath = fs.path.join(dataPath, 'bad_package');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
DartDependencySetBuilder(mainPath, packagesPath);
try {
builder.build();
fail('expect an exception to be thrown.');
} on DartDependencyException catch (error) {
expect(error.toString(), contains('rochambeau'));
expect(error.toString(), contains('pubspec.yaml'));
}
});
testUsingContext('does not change ASCII casing of path', () {
final String testPath = fs.path.join(dataPath, 'asci_casing');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder = DartDependencySetBuilder(mainPath, packagesPath);
final Set<String> deps = builder.build();
expect(deps, contains(endsWith('This_Import_Has_fuNNy_casING.dart')));
});
testUsingContext('bad_import', () {
final String testPath = fs.path.join(dataPath, 'bad_import');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
DartDependencySetBuilder(mainPath, packagesPath);
try {
builder.build();
fail('expect an exception to be thrown.');
} on DartDependencyException catch (error) {
expect(error.toString(), contains("Couldn't parse URI"));
}
});
});
}