Skip to content

Commit

Permalink
Move 'onPlatform' arguments for tests and groups up. (#3890)
Browse files Browse the repository at this point in the history
With named-arguments-anywhere, `onPlatform` can be specified before the group
or test's closure. Doing so makes the group or test must more readable.
  • Loading branch information
srawlins authored Sep 26, 2024
1 parent e8f2333 commit c613f42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 11 additions & 7 deletions test/html_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import 'package:test/test.dart';
import 'src/utils.dart' as utils;

void main() {
group('HTML generator tests', () {
group('HTML generator tests', onPlatform: {
'windows': Skip('Tests do not work on Windows after NNBD conversion')
}, () {
late MemoryResourceProvider resourceProvider;
late path.Context pathContext;

Expand Down Expand Up @@ -86,7 +88,9 @@ void main() {
}
});

test('libraries with no duplicates are not warned about', () async {
test('libraries with no duplicates are not warned about',
onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')},
() async {
getConvertedFile('$projectPath/lib/a.dart')
.writeAsStringSync('library a;');
getConvertedFile('$projectPath/lib/b.dart')
Expand All @@ -96,9 +100,11 @@ void main() {
await generator.generate(packageGraph);

expect(packageGraph.packageWarningCounter.errorCount, 0);
}, onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')});
});

test('libraries with duplicate names are warned about', () async {
test('libraries with duplicate names are warned about',
onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')},
() async {
getConvertedFile('$projectPath/lib/a.dart')
.writeAsStringSync('library a;');
getConvertedFile('$projectPath/lib/b.dart')
Expand All @@ -112,9 +118,7 @@ void main() {
packageGraph.localPublicLibraries,
anyElement((Library l) => packageGraph.packageWarningCounter
.hasWarning(l, PackageWarning.duplicateFile, expectedPath)));
}, onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')});
}, onPlatform: {
'windows': Skip('Tests do not work on Windows after NNBD conversion')
});
});
}

Expand Down
6 changes: 4 additions & 2 deletions test/libraries_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ A doc comment.
);
});

test('libraries in SDK package have appropriate data', () async {
test('libraries in SDK package have appropriate data',
onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')},
() async {
var packageMetaProvider = testPackageMetaProvider;
var sdkFolder = packageMetaProvider.defaultSdkDir;
var packageConfigProvider = getTestPackageConfigProvider(sdkFolder.path);
Expand All @@ -173,7 +175,7 @@ A doc comment.
expect(dartAsyncLib.dirName, 'dart-async');
expect(dartAsyncLib.href,
'${htmlBasePlaceholder}dart-async/dart-async-library.html');
}, onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')});
});
}

@reflectiveTest
Expand Down
13 changes: 4 additions & 9 deletions test/packages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void main() {

tearDown(clearPackageMetaCache);

group('tests', () {
group('tests',
onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')},
() {
group('typical package', () {
setUp(() {
optionSet.parseArguments([]);
Expand Down Expand Up @@ -120,13 +122,6 @@ int x;
equals('https://github.com/dart-lang'));
});

test('has a public library', () async {
var packageGraph = await utils.bootBasicPackage(
projectPath, packageMetaProvider, packageConfigProvider);
var library = packageGraph.libraries.named('a');
expect(library.isDocumented, true);
});

test('has anonymous libraries', () async {
writeToJoinedPath(['lib', 'b.dart'], '''
/// Documentation comment.
Expand Down Expand Up @@ -492,5 +487,5 @@ int x;
expect(packageGraph.localPackages.first.categories, isEmpty);
});
});
}, onPlatform: {'windows': Skip('Test does not work on Windows (#2446)')});
});
}

0 comments on commit c613f42

Please sign in to comment.