Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: sdk/lib/_internal/pub_generated/test/package_list_files_test.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub_generated/test/package_list_files_test.dart
diff --git a/sdk/lib/_internal/pub_generated/test/package_list_files_test.dart b/sdk/lib/_internal/pub_generated/test/package_list_files_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..466ee82e9a642e8393ff480bdb1f8ab46166625e
--- /dev/null
+++ b/sdk/lib/_internal/pub_generated/test/package_list_files_test.dart
@@ -0,0 +1,211 @@
+library packages_list_files_test;
+import 'package:path/path.dart' as path;
+import 'package:scheduled_test/scheduled_test.dart';
+import '../lib/src/entrypoint.dart';
+import '../lib/src/io.dart';
+import '../lib/src/system_cache.dart';
+import 'descriptor.dart' as d;
+import 'test_pub.dart';
+var root;
+var entrypoint;
+main() {
+ initConfig();
+ group('not in a git repo', () {
+ setUp(() {
+ d.appDir().create();
+ scheduleEntrypoint();
+ });
+ integration('lists files recursively', () {
+ d.dir(
+ appPath,
+ [
+ d.file('file1.txt', 'contents'),
+ d.file('file2.txt', 'contents'),
+ d.dir(
+ 'subdir',
+ [
+ d.file('subfile1.txt', 'subcontents'),
+ d.file('subfile2.txt', 'subcontents')])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ unorderedEquals(
+ [
+ path.join(root, 'pubspec.yaml'),
+ path.join(root, 'file1.txt'),
+ path.join(root, 'file2.txt'),
+ path.join(root, 'subdir', 'subfile1.txt'),
+ path.join(root, 'subdir', 'subfile2.txt')]));
+ });
+ });
+ commonTests();
+ });
+ group('with git', () {
+ setUp(() {
+ ensureGit();
+ d.git(appPath, [d.appPubspec()]).create();
+ scheduleEntrypoint();
+ });
+ integration("includes files that are or aren't checked in", () {
+ d.dir(
+ appPath,
+ [
+ d.file('file1.txt', 'contents'),
+ d.file('file2.txt', 'contents'),
+ d.dir(
+ 'subdir',
+ [
+ d.file('subfile1.txt', 'subcontents'),
+ d.file('subfile2.txt', 'subcontents')])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ unorderedEquals(
+ [
+ path.join(root, 'pubspec.yaml'),
+ path.join(root, 'file1.txt'),
+ path.join(root, 'file2.txt'),
+ path.join(root, 'subdir', 'subfile1.txt'),
+ path.join(root, 'subdir', 'subfile2.txt')]));
+ });
+ });
+ integration("ignores files that are gitignored", () {
+ d.dir(
+ appPath,
+ [
+ d.file('.gitignore', '*.txt'),
+ d.file('file1.txt', 'contents'),
+ d.file('file2.text', 'contents'),
+ d.dir(
+ 'subdir',
+ [
+ d.file('subfile1.txt', 'subcontents'),
+ d.file('subfile2.text', 'subcontents')])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ unorderedEquals(
+ [
+ path.join(root, 'pubspec.yaml'),
+ path.join(root, '.gitignore'),
+ path.join(root, 'file2.text'),
+ path.join(root, 'subdir', 'subfile2.text')]));
+ });
+ });
+ commonTests();
+ });
+}
+void scheduleEntrypoint() {
+ schedule(() {
+ root = path.join(sandboxDir, appPath);
+ entrypoint = new Entrypoint(root, new SystemCache.withSources(root));
+ }, 'initializing entrypoint');
+ currentSchedule.onComplete.schedule(() {
+ entrypoint = null;
+ }, 'nulling entrypoint');
+}
+void commonTests() {
+ integration('ignores broken symlinks', () {
+ d.dir(appPath, [d.dir('target')]).create();
+ scheduleSymlink(path.join(appPath, 'target'), path.join(appPath, 'link'));
+ schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'target')));
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ equals([path.join(root, 'pubspec.yaml')]));
+ });
+ });
+ integration('ignores pubspec.lock files', () {
+ d.dir(
+ appPath,
+ [d.file('pubspec.lock'), d.dir('subdir', [d.file('pubspec.lock')])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ equals([path.join(root, 'pubspec.yaml')]));
+ });
+ });
+ integration('ignores packages directories', () {
+ d.dir(
+ appPath,
+ [
+ d.dir('packages', [d.file('file.txt', 'contents')]),
+ d.dir(
+ 'subdir',
+ [d.dir('packages', [d.file('subfile.txt', 'subcontents')])])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ equals([path.join(root, 'pubspec.yaml')]));
+ });
+ });
+ integration('allows pubspec.lock directories', () {
+ d.dir(
+ appPath,
+ [d.dir('pubspec.lock', [d.file('file.txt', 'contents')])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(),
+ unorderedEquals(
+ [
+ path.join(root, 'pubspec.yaml'),
+ path.join(root, 'pubspec.lock', 'file.txt')]));
+ });
+ });
+ group('and "beneath"', () {
+ integration('only lists files beneath the given root', () {
+ d.dir(
+ appPath,
+ [
+ d.file('file1.txt', 'contents'),
+ d.file('file2.txt', 'contents'),
+ d.dir(
+ 'subdir',
+ [
+ d.file('subfile1.txt', 'subcontents'),
+ d.file('subfile2.txt', 'subcontents'),
+ d.dir(
+ 'subsubdir',
+ [
+ d.file('subsubfile1.txt', 'subsubcontents'),
+ d.file('subsubfile2.txt', 'subsubcontents')])])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(beneath: path.join(root, 'subdir')),
+ unorderedEquals(
+ [
+ path.join(root, 'subdir', 'subfile1.txt'),
+ path.join(root, 'subdir', 'subfile2.txt'),
+ path.join(root, 'subdir', 'subsubdir', 'subsubfile1.txt'),
+ path.join(root, 'subdir', 'subsubdir', 'subsubfile2.txt')]));
+ });
+ });
+ integration("doesn't care if the root is blacklisted", () {
+ d.dir(
+ appPath,
+ [
+ d.file('file1.txt', 'contents'),
+ d.file('file2.txt', 'contents'),
+ d.dir(
+ 'packages',
+ [
+ d.file('subfile1.txt', 'subcontents'),
+ d.file('subfile2.txt', 'subcontents'),
+ d.dir(
+ 'subsubdir',
+ [
+ d.file('subsubfile1.txt', 'subsubcontents'),
+ d.file('subsubfile2.txt', 'subsubcontents')])])]).create();
+ schedule(() {
+ expect(
+ entrypoint.root.listFiles(beneath: path.join(root, 'packages')),
+ unorderedEquals(
+ [
+ path.join(root, 'packages', 'subfile1.txt'),
+ path.join(root, 'packages', 'subfile2.txt'),
+ path.join(root, 'packages', 'subsubdir', 'subsubfile1.txt'),
+ path.join(root, 'packages', 'subsubdir', 'subsubfile2.txt')]));
+ });
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698