|
| 1 | +// Copyright (c) 2024, 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 | +@TestOn('vm') |
| 6 | +@Tags(['integration']) |
| 7 | +library; |
| 8 | + |
| 9 | +import 'dart:async'; |
| 10 | + |
| 11 | +import 'package:test/test.dart'; |
| 12 | +import 'package:test_descriptor/test_descriptor.dart' as d; |
| 13 | + |
| 14 | +import 'common/utils.dart'; |
| 15 | + |
| 16 | +// This doesn't actually change anything since we're using precompiled tests, |
| 17 | +// but it gets the compiler selector in tests right. |
| 18 | +const _testArgs = ['-c', 'dart2wasm']; |
| 19 | + |
| 20 | +void main() { |
| 21 | + group('Can run tests using dart2wasm', () { |
| 22 | + test('via build.yaml config flag', () async { |
| 23 | + await expectTestsPass( |
| 24 | + usePrecompiled: true, |
| 25 | + buildArgs: [ |
| 26 | + '--config=dart2wasm', |
| 27 | + '--output=${d.sandbox}', |
| 28 | + ], |
| 29 | + testArgs: _testArgs, |
| 30 | + ); |
| 31 | + await _expectWasCompiledWithDart2Wasm(); |
| 32 | + }, onPlatform: {'windows': const Skip('flaky on windows')}); |
| 33 | + |
| 34 | + test('via --define flag', () async { |
| 35 | + await expectTestsPass( |
| 36 | + usePrecompiled: true, |
| 37 | + buildArgs: [ |
| 38 | + '--define', |
| 39 | + 'build_web_compilers:entrypoint=compiler=dart2wasm', |
| 40 | + '--define', |
| 41 | + 'build_web_compilers:entrypoint=dart2wasm_args=' |
| 42 | + '["--enable-asserts", "-E--enable-experimental-ffi"]', |
| 43 | + '--output=${d.sandbox}', |
| 44 | + ], |
| 45 | + testArgs: _testArgs, |
| 46 | + ); |
| 47 | + await _expectWasCompiledWithDart2Wasm(); |
| 48 | + }, onPlatform: {'windows': const Skip('flaky on windows')}); |
| 49 | + |
| 50 | + test('via --release mode', () async { |
| 51 | + await expectTestsPass( |
| 52 | + usePrecompiled: true, |
| 53 | + buildArgs: [ |
| 54 | + '--release', |
| 55 | + '--config=dart2wasm', |
| 56 | + '--output=${d.sandbox}', |
| 57 | + ], |
| 58 | + testArgs: _testArgs, |
| 59 | + ); |
| 60 | + await _expectWasCompiledWithDart2Wasm(); |
| 61 | + }, onPlatform: {'windows': const Skip('flaky on windows')}); |
| 62 | + }); |
| 63 | +} |
| 64 | + |
| 65 | +Future<void> _expectWasCompiledWithDart2Wasm() async { |
| 66 | + await d.dir( |
| 67 | + 'test', |
| 68 | + [ |
| 69 | + d.file( |
| 70 | + 'hello_world_deferred_test.dart.browser_test.wasm', |
| 71 | + anything, |
| 72 | + ), |
| 73 | + ], |
| 74 | + ).validate(); |
| 75 | +} |
0 commit comments