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

Unified Diff: sdk/lib/_internal/pub/test/lish/many_files_test.dart

Issue 1013753015: Limit the length of file paths used in many_files_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/test/lish/many_files_test.dart
diff --git a/sdk/lib/_internal/pub/test/lish/many_files_test.dart b/sdk/lib/_internal/pub/test/lish/many_files_test.dart
index 3ca75c4ba904817178ba8465950e1f79df9a4afd..1adec26fa570943988428aa9719c823f8d00103e 100644
--- a/sdk/lib/_internal/pub/test/lish/many_files_test.dart
+++ b/sdk/lib/_internal/pub/test/lish/many_files_test.dart
@@ -16,20 +16,19 @@ import '../descriptor.dart' as d;
import '../test_pub.dart';
import 'utils.dart';
-/// The depth of directories to use when creating files to tickle
-/// argument-length limits.
-final _depth = 10;
-
-/// The maximum number of characters in a path component.
+/// The maximum number of bytes in an entire path.
+///
+/// This is [Windows's number][MAX_PATH], which is a much tighter constraint
+/// than OS X or Linux. We use it everywhere for consistency.
///
-/// Only Windows has this tight of a constraint, but we abide by it on all
-/// operating systems to avoid specializing the test too much.
-final _componentMax = 255;
+/// [MAX_PATH]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383130(v=vs.85).aspx
+const _pathMax = 260;
main() {
initConfig();
- integration('archives and uploads a package', () {
+ integration('archives and uploads a package with more files than can fit on '
+ 'the command line', () {
d.validPackage.create();
var argMax;
@@ -49,21 +48,28 @@ main() {
}
schedule(() {
- var dir = p.join(sandboxDir, appPath);
- for (var i = 0; i < _depth; i++) {
- dir = p.join(dir, "x" * _componentMax);
- new Directory(dir).createSync();
- }
+ var appRoot = p.join(sandboxDir, appPath);
+
+ // We'll make the filenames as long as possible to reduce the number of
+ // files we have to create to hit the maximum. However, the tar process
+ // uses relative paths, which means we can't count the root as part of the
+ // length.
+ var lengthPerFile = _pathMax - appRoot.length;
+
+ // Create enough files to hit [argMax]. This may be a slight overestimate,
+ // since other options are passed to the tar command line, but we don't
+ // know how long those will be.
+ var filesToCreate = (argMax / lengthPerFile).ceil();
- var pathLength = (_componentMax + 1) * _depth;
- var filesToCreate = (argMax / pathLength).ceil();
for (var i = 0; i < filesToCreate; i++) {
- var filePath = p.join(dir, "x" * _componentMax);
var iString = i.toString();
- filePath = filePath.substring(0, filePath.length - iString.length) +
- iString;
- new File(filePath).writeAsStringSync("");
+ // The file name contains "x"s to make the path hit [_pathMax],
+ // followed by a number to distinguish different files.
+ var fileName =
+ "x" * (_pathMax - appRoot.length - iString.length - 1) + iString;
+
+ new File(p.join(appRoot, fileName)).writeAsStringSync("");
}
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698