|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a
|
3 | 3 | // BSD-style license that can be found in the LICENSE file.
|
4 | 4 |
|
5 |
| -@Timeout(const Duration(minutes: 8)) |
| 5 | +@Timeout(const Duration(minutes: 5)) |
6 | 6 |
|
7 | 7 | import 'dart:io';
|
8 | 8 |
|
@@ -69,6 +69,61 @@ void main() {
|
69 | 69 | });
|
70 | 70 | }
|
71 | 71 | });
|
| 72 | + |
| 73 | + group('should serve with valid configuration', () { |
| 74 | + for (var withDDC in [true, false]) { |
| 75 | + test(withDDC ? 'DDC' : 'dart2js', () async { |
| 76 | + var openPort = await getOpenPort(); |
| 77 | + var args = ['serve', 'web:$openPort']; |
| 78 | + if (!withDDC) { |
| 79 | + args.add('--release'); |
| 80 | + } |
| 81 | + |
| 82 | + var process = await runWebDev(args, workingDirectory: exampleDirectory); |
| 83 | + |
| 84 | + var expectedItems = <Object>['[INFO] Succeeded']; |
| 85 | + if (!withDDC) { |
| 86 | + expectedItems.add(anyOf( |
| 87 | + contains('with 0 outputs'), contains('Running dart2js with'))); |
| 88 | + } |
| 89 | + |
| 90 | + var hostUrl = 'http://localhost:$openPort'; |
| 91 | + |
| 92 | + await expectLater( |
| 93 | + process.stdout, emitsThrough('Serving `web` on $hostUrl')); |
| 94 | + |
| 95 | + var client = new HttpClient(); |
| 96 | + |
| 97 | + try { |
| 98 | + for (var entry in _testItems.entries) { |
| 99 | + var url = Uri.parse('$hostUrl/${entry.key}'); |
| 100 | + |
| 101 | + var request = await client.getUrl(url); |
| 102 | + var response = await request.close(); |
| 103 | + |
| 104 | + var shouldExist = (entry.value ?? withDDC) == withDDC; |
| 105 | + |
| 106 | + if (entry.key == 'main.ddc.js') { |
| 107 | + // This file SHOULD NOT be output in dart2js mode |
| 108 | + // But there is an issue here |
| 109 | + // https://github.com/dart-lang/build/issues/1033 |
| 110 | + shouldExist = true; |
| 111 | + } |
| 112 | + |
| 113 | + var expectedStatusCode = shouldExist ? 200 : 404; |
| 114 | + |
| 115 | + expect(response.statusCode, expectedStatusCode); |
| 116 | + } |
| 117 | + } finally { |
| 118 | + client.close(force: true); |
| 119 | + } |
| 120 | + |
| 121 | + process.signal(ProcessSignal.SIGTERM); |
| 122 | + |
| 123 | + await process.shouldExit(-15); |
| 124 | + }); |
| 125 | + } |
| 126 | + }); |
72 | 127 | }
|
73 | 128 |
|
74 | 129 | /// Returns an environment map that includes `PUB_ENVIRONMENT`.
|
|
0 commit comments