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

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

Issue 1165473002: Start pulling pub from its own repo. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 file.
4
5 import 'dart:convert';
6 import 'dart:io';
7 import 'dart:math' as math;
8
9 import 'package:path/path.dart' as p;
10 import 'package:scheduled_test/scheduled_test.dart';
11 import 'package:scheduled_test/scheduled_server.dart';
12 import 'package:shelf/shelf.dart' as shelf;
13
14 import '../../lib/src/exit_codes.dart' as exit_codes;
15 import '../descriptor.dart' as d;
16 import '../test_pub.dart';
17 import 'utils.dart';
18
19 /// The maximum number of bytes in an entire path.
20 ///
21 /// This is [Windows's number][MAX_PATH], which is a much tighter constraint
22 /// than OS X or Linux. We subtract one because Windows counts it as the number
23 /// of bytes in a path C string including the terminating NUL but we only count
24 /// characters here.
25 ///
26 /// We use this limit on all platforms for consistency.
27 ///
28 /// [MAX_PATH]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa38313 0(v=vs.85).aspx
29 const _pathMax = 260 - 1;
30
31 main() {
32 initConfig();
33
34 integration('archives and uploads a package with more files than can fit on '
35 'the command line', () {
36 d.validPackage.create();
37
38 var argMax;
39 if (Platform.isWindows) {
40 // On Windows, the maximum argument list length is 8^5 bytes.
41 argMax = math.pow(8, 5);
42 } else {
43 // On POSIX, the maximum argument list length can be retrieved
44 // automatically.
45 var result = Process.runSync("getconf", ["ARG_MAX"]);
46 if (result.exitCode != 0) {
47 fail("getconf failed with exit code ${result.exitCode}:\n"
48 "${result.stderr}");
49 }
50
51 argMax = int.parse(result.stdout);
52 }
53
54 schedule(() {
55 var appRoot = p.join(sandboxDir, appPath);
56
57 // We'll make the filenames as long as possible to reduce the number of
58 // files we have to create to hit the maximum. However, the tar process
59 // uses relative paths, which means we can't count the root as part of the
60 // length.
61 var lengthPerFile = _pathMax - appRoot.length;
62
63 // Create enough files to hit [argMax]. This may be a slight overestimate,
64 // since other options are passed to the tar command line, but we don't
65 // know how long those will be.
66 var filesToCreate = (argMax / lengthPerFile).ceil();
67
68 for (var i = 0; i < filesToCreate; i++) {
69 var iString = i.toString();
70
71 // The file name contains "x"s to make the path hit [_pathMax],
72 // followed by a number to distinguish different files.
73 var fileName =
74 "x" * (_pathMax - appRoot.length - iString.length - 1) + iString;
75
76 new File(p.join(appRoot, fileName)).writeAsStringSync("");
77 }
78 });
79
80 var server = new ScheduledServer();
81 d.credentialsFile(server, 'access token').create();
82 var pub = startPublish(server);
83
84 confirmPublish(pub);
85 handleUploadForm(server);
86 handleUpload(server);
87
88 server.handle('GET', '/create', (request) {
89 return new shelf.Response.ok(JSON.encode({
90 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
91 }));
92 });
93
94 pub.stdout.expect(startsWith('Uploading...'));
95 pub.stdout.expect('Package test_pkg 1.0.0 uploaded!');
96 pub.shouldExit(exit_codes.SUCCESS);
97 });
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698