Skip to content

Commit

Permalink
add test validating current behavior of packageOf, run CI on windows (#…
Browse files Browse the repository at this point in the history
…137)

- validates the behavior of #136 today (but does not change it)
- removes build_runner deps for testing, there is no need to use it for such a small package
- fixes a bug in discovery_test.dart that was probably landed due to inability to run tests
  • Loading branch information
jakemac53 committed Jan 10, 2024
1 parent 3e7d93c commit 5a0bc19
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
sdk: [3.2, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand All @@ -57,5 +56,5 @@ jobs:
name: Install dependencies
run: dart pub get
- name: Run tests
run: dart run build_runner test -- -p chrome,vm
run: dart test -p chrome,vm
if: always() && steps.install.outcome == 'success'
3 changes: 0 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ dependencies:
path: ^1.8.0

dev_dependencies:
build_runner: ^2.0.0
build_test: ^2.1.2
build_web_compilers: ^4.0.0
dart_flutter_team_lints: ^2.0.0
test: ^1.16.0
2 changes: 1 addition & 1 deletion test/discovery_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
fileTest('package_config.json', {
'.packages': 'invalid .packages file',
'script.dart': 'main(){}',
'packages': {'shouldNotBeFound': <Never>{}},
'packages': {'shouldNotBeFound': <Never, Never>{}},
'.dart_tool': {
'package_config.json': packageConfigFile,
}
Expand Down
19 changes: 19 additions & 0 deletions test/parse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,25 @@ void main() {
Uri.parse('package:qux/diz'));
});

test('packageOf is case sensitive on windows', () {
var configBytes = utf8.encode(json.encode({
'configVersion': 2,
'packages': [
{'name': 'foo', 'rootUri': 'file:///C:/Foo/', 'packageUri': 'lib/'},
]
}));
var config = parsePackageConfigBytes(
// ignore: unnecessary_cast
configBytes as Uint8List,
Uri.parse('file:///C:/tmp/.dart_tool/file.dart'),
throwError);
expect(config.version, 2);
expect(
config.packageOf(Uri.parse('file:///C:/foo/lala/lala.dart')), null);
expect(config.packageOf(Uri.parse('file:///C:/Foo/lala/lala.dart'))!.name,
'foo');
});

group('invalid', () {
void testThrows(String name, String source) {
test(name, () {
Expand Down

0 comments on commit 5a0bc19

Please sign in to comment.