|
| 1 | +// Copyright (c) 2025, 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:io'; |
| 6 | + |
| 7 | +import 'package:hooks_runner/hooks_runner.dart'; |
| 8 | +import 'package:test/test.dart'; |
| 9 | + |
| 10 | +import '../helpers.dart'; |
| 11 | +import 'helpers.dart'; |
| 12 | + |
| 13 | +void main() { |
| 14 | + test('hooks have access to http proxy variable', () async { |
| 15 | + final server = await HttpServer.bind(InternetAddress.anyIPv4, 0); |
| 16 | + server.listen((request) async { |
| 17 | + expect(request.headers.host, 'testing_proxy.dart.dev'); |
| 18 | + expect(request.uri.path, '/test_asset'); |
| 19 | + |
| 20 | + final response = request.response; |
| 21 | + response.statusCode = 200; |
| 22 | + response.writeln('test body response'); |
| 23 | + await response.close(); |
| 24 | + }); |
| 25 | + |
| 26 | + addTearDown(server.close); |
| 27 | + final port = server.port; |
| 28 | + |
| 29 | + await inTempDir((tempUri) async { |
| 30 | + await copyTestProjects(targetUri: tempUri); |
| 31 | + final packageUri = tempUri.resolve('download_assets/'); |
| 32 | + await runPubGet(workingDirectory: packageUri, logger: logger); |
| 33 | + |
| 34 | + final result = await runProcess( |
| 35 | + executable: dartExecutable, |
| 36 | + arguments: [ |
| 37 | + pkgNativeAssetsBuilderUri |
| 38 | + .resolve('test/build_runner/build_process_helper.dart') |
| 39 | + .toFilePath(), |
| 40 | + packageUri.toFilePath(), |
| 41 | + Target.current.toString(), |
| 42 | + ], |
| 43 | + workingDirectory: packageUri, |
| 44 | + logger: logger, |
| 45 | + environment: {'HTTP_PROXY': 'localhost:$port'}, |
| 46 | + ); |
| 47 | + expect(result.exitCode, 0); |
| 48 | + }); |
| 49 | + }); |
| 50 | +} |
0 commit comments