Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ All configuration options for the local task discovery are found on the
<td><code>env</code></td>
<td><code>Environment</code></td>
<td><code>Environment.browser</code></td>
<td>The environment to run tests in ('vm' or 'browser')</td>
<td>The environment to run tests in ('vm', 'browser', 'both')</td>
</tr>
<tr>
<td><code>filename</code></td>
Expand Down
13 changes: 8 additions & 5 deletions lib/src/tasks/gen_test_runner/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ Future<GenTestRunnerTask> genTestRunner(TestRunnerConfig currentConfig) async {
}
});

if (currentConfig.genHtml && !currentConfig.check) {
await testHtmlFileGenerator(
currentDirectory, currentConfig.filename, currentConfig.htmlHeaders);
}

if (currentConfig.env == Environment.browser) {
if (currentConfig.genHtml && !currentConfig.check) {
await testHtmlFileGenerator(
currentDirectory, currentConfig.filename, currentConfig.htmlHeaders);
}
runnerLines.add('@TestOn(\'browser\')');
} else {
} else if (currentConfig.env == Environment.vm) {
runnerLines.add('@TestOn(\'vm\')');
} else {
runnerLines.add('@TestOn(\'browser || vm\')');
}
runnerLines.add(
'library ${currentDirectory.replaceAll('/','.')}${currentConfig.filename};');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tasks/gen_test_runner/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const bool defaultGenHtml = false;
const bool defaultReact = true;
const List<String> defaultHtmlHeaders = const [];

enum Environment { vm, browser }
enum Environment { vm, browser, both }

class TestRunnerConfig {
bool check = defaultCheck;
Expand Down
13 changes: 13 additions & 0 deletions test/integration/gen_test_runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'package:path/path.dart' as path;
import 'package:test/test.dart';

const String browserAndVm = 'test_fixtures/gen_test_runner/browser_and_vm';
const String browserAndVmRunner =
'test_fixtures/gen_test_runner/browser_and_vm_runner';
const String checkFail = 'test_fixtures/gen_test_runner/check_fail';
const String checkPass = 'test_fixtures/gen_test_runner/check_pass';
const String defaultConfig = 'test_fixtures/gen_test_runner/default_config';
Expand Down Expand Up @@ -101,6 +103,17 @@ void main() {
shouldFileExist: false);
});

test('should create runner with both vm and browser annotation', () async {
Runner runner = await generateTestRunner(browserAndVmRunner);
expect(runner.exitCode, isZero);
String runnerPath =
path.join(browserAndVmRunner, 'test/generated_runner.dart');
File testRunner = new File(runnerPath);
String fileContents = testRunner.readAsStringSync();
expect(fileContents.contains('@TestOn(\'browser || vm\')'), isTrue);
verifyExistenceAndCleanup(runnerPath, shouldFileExist: true);
});

group('--check flag', () {
test('should succeed if the runner is up to date', () async {
Runner runner =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: test_generator_browser_and_vm_runner
version: 0.0.0
dev_dependencies:
dart_dev:
path: ../../..
test: '^0.12.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@TestOn('browser')
library test_generator_browser_and_vm_runner.test.browser.browser_test;

import 'package:test/test.dart';

main() {
test('browser test', () {
expect(true, isTrue);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@TestOn('vm')
library test_generator_browser_and_vm_runner.test.vm.vm_test;

import 'package:test/test.dart';

main() {
test('vm test', () {
expect(true, isTrue);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library test_generator_browser_and_vm_runner.tool.dev;

import 'package:dart_dev/dart_dev.dart';

main(List<String> args) async {
config.genTestRunner.configs = [
new TestRunnerConfig(env: Environment.both, directory: 'test/'),
];

await dev(args);
}