OLD | NEW |
(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 depth of directories to use when creating files to tickle |
| 20 /// argument-length limits. |
| 21 final _depth = 10; |
| 22 |
| 23 /// The maximum number of characters in a path component. |
| 24 /// |
| 25 /// Only Windows has this tight of a constraint, but we abide by it on all |
| 26 /// operating systems to avoid specializing the test too much. |
| 27 final _componentMax = 255; |
| 28 |
| 29 main() { |
| 30 initConfig(); |
| 31 |
| 32 integration('archives and uploads a package', () { |
| 33 d.validPackage.create(); |
| 34 |
| 35 var argMax; |
| 36 if (Platform.isWindows) { |
| 37 // On Windows, the maximum argument list length is 8^5 bytes. |
| 38 argMax = math.pow(8, 5); |
| 39 } else { |
| 40 // On POSIX, the maximum argument list length can be retrieved |
| 41 // automatically. |
| 42 var result = Process.runSync("getconf", ["ARG_MAX"]); |
| 43 if (result.exitCode != 0) { |
| 44 fail("getconf failed with exit code ${result.exitCode}:\n" |
| 45 "${result.stderr}"); |
| 46 } |
| 47 |
| 48 argMax = int.parse(result.stdout); |
| 49 } |
| 50 |
| 51 schedule(() { |
| 52 var dir = p.join(sandboxDir, appPath); |
| 53 for (var i = 0; i < _depth; i++) { |
| 54 dir = p.join(dir, "x" * _componentMax); |
| 55 new Directory(dir).createSync(); |
| 56 } |
| 57 |
| 58 var pathLength = (_componentMax + 1) * _depth; |
| 59 var filesToCreate = (argMax / pathLength).ceil(); |
| 60 for (var i = 0; i < filesToCreate; i++) { |
| 61 var filePath = p.join(dir, "x" * _componentMax); |
| 62 var iString = i.toString(); |
| 63 filePath = filePath.substring(0, filePath.length - iString.length) + |
| 64 iString; |
| 65 |
| 66 new File(filePath).writeAsStringSync(""); |
| 67 } |
| 68 }); |
| 69 |
| 70 var server = new ScheduledServer(); |
| 71 d.credentialsFile(server, 'access token').create(); |
| 72 var pub = startPublish(server); |
| 73 |
| 74 confirmPublish(pub); |
| 75 handleUploadForm(server); |
| 76 handleUpload(server); |
| 77 |
| 78 server.handle('GET', '/create', (request) { |
| 79 return new shelf.Response.ok(JSON.encode({ |
| 80 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'} |
| 81 })); |
| 82 }); |
| 83 |
| 84 pub.stdout.expect(startsWith('Uploading...')); |
| 85 pub.stdout.expect('Package test_pkg 1.0.0 uploaded!'); |
| 86 pub.shouldExit(exit_codes.SUCCESS); |
| 87 }); |
| 88 } |
OLD | NEW |