Skip to content

Commit

Permalink
Require Dart 3.3 (#88)
Browse files Browse the repository at this point in the history
update lints, test on wasm
  • Loading branch information
kevmoo authored Feb 28, 2024
1 parent ef5f065 commit 379d60c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [2.18.0, dev]
sdk: [3.3, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
Expand All @@ -67,3 +67,6 @@ jobs:
- name: Run Node tests
run: dart test --platform node
if: always() && steps.install.outcome == 'success'
- name: Run Chrome tests - wasm
run: dart test --platform chrome --compiler dart2wasm
if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.3-wip

- Require Dart 3.3.

## 2.1.2

- Allow `file` version `7.x`.
Expand Down
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ linter:
- avoid_unused_constructor_parameters
- cancel_subscriptions
- package_api_docs
- test_types_in_equals
- use_super_parameters
3 changes: 2 additions & 1 deletion lib/glob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class Glob implements Pattern {
/// The parsed AST of the glob.
final AstNode _ast;

/// The underlying object used to implement [list] and [listSync].
/// The underlying object used to implement [listFileSystem] and
/// [listFileSystemSync].
///
/// This should not be read directly outside of [_listTreeForFileSystem].
ListTree? _listTree;
Expand Down
3 changes: 2 additions & 1 deletion lib/list_local_fs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:glob/glob.dart';

import 'glob.dart';

/// Platform specific extensions for where `dart:io` exists, which use the
/// local file system.
Expand Down
19 changes: 11 additions & 8 deletions lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class AstNode {
/// In particular, this returns a glob AST with two guarantees:
///
/// 1. There are no [OptionsNode]s other than the one at the top level.
/// 2. It matches the same set of paths as [this].
/// 2. It matches the same set of paths as `this`.
///
/// For example, given the glob `{foo,bar}/{click/clack}`, this would return
/// `{foo/click,foo/clack,bar/click,bar/clack}`.
Expand Down Expand Up @@ -189,10 +189,10 @@ class SequenceNode extends AstNode {
@override
bool operator ==(Object other) =>
other is SequenceNode &&
const IterableEquality().equals(nodes, other.nodes);
const IterableEquality<AstNode>().equals(nodes, other.nodes);

@override
int get hashCode => const IterableEquality().hash(nodes);
int get hashCode => const IterableEquality<AstNode>().hash(nodes);

@override
String toString() => nodes.join();
Expand Down Expand Up @@ -343,10 +343,11 @@ class RangeNode extends AstNode {
bool operator ==(Object other) =>
other is RangeNode &&
other.negated == negated &&
SetEquality().equals(ranges, other.ranges);
const SetEquality<Range>().equals(ranges, other.ranges);

@override
int get hashCode => (negated ? 1 : 3) * const SetEquality().hash(ranges);
int get hashCode =>
(negated ? 1 : 3) * const SetEquality<Range>().hash(ranges);

@override
String toString() {
Expand Down Expand Up @@ -389,10 +390,12 @@ class OptionsNode extends AstNode {
@override
bool operator ==(Object other) =>
other is OptionsNode &&
const UnorderedIterableEquality().equals(options, other.options);
const UnorderedIterableEquality<SequenceNode>()
.equals(options, other.options);

@override
int get hashCode => const UnorderedIterableEquality().hash(options);
int get hashCode =>
const UnorderedIterableEquality<SequenceNode>().hash(options);

@override
String toString() => '{${options.join(',')}}';
Expand All @@ -412,7 +415,7 @@ class LiteralNode extends AstNode {
bool get canMatchAbsolute {
var nativeText =
_context!.style == p.Style.windows ? text.replaceAll('/', '\\') : text;
return _context!.isAbsolute(nativeText);
return _context.isAbsolute(nativeText);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Range {
/// Returns a range that covers only [value].
Range.singleton(int value) : this(value, value);

/// Whether [this] contains [value].
/// Whether `this` contains [value].
bool contains(int value) => value >= min && value <= max;

@override
Expand All @@ -31,7 +31,7 @@ class Range {
int get hashCode => 3 * min + 7 * max;
}

/// An implementation of [Match] constructed by [Glob]s.
/// An implementation of [Match] constructed by `Glob`s.
class GlobMatch implements Match {
@override
final String input;
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: glob
version: 2.1.2
version: 2.1.3-wip
description: A library to perform Bash-style file and directory globbing.
repository: https://github.com/dart-lang/glob

environment:
sdk: '>=2.19.0 <4.0.0'
sdk: ^3.3.0

dependencies:
async: ^2.5.0
Expand All @@ -14,6 +14,6 @@ dependencies:
string_scanner: ^1.1.0

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
dart_flutter_team_lints: ^2.0.0
test: ^1.17.0
test_descriptor: ^2.0.0
20 changes: 12 additions & 8 deletions test/list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ void main() {
test('returns empty list for non-existent case-sensitive directories',
() async {
expect(await Glob('non/existent/**', caseSensitive: true).list().toList(),
[]);
<Never>[]);
});

test('returns empty list for non-existent case-insensitive directories',
() async {
expect(
await Glob('non/existent/**', caseSensitive: false).list().toList(),
[]);
<Never>[]);
});
});

Expand All @@ -48,26 +48,30 @@ void main() {
});

test('returns empty list for non-existent case-sensitive directories', () {
expect(Glob('non/existent/**', caseSensitive: true).listSync(), []);
expect(
Glob('non/existent/**', caseSensitive: true).listSync(), <Never>[]);
});

test('returns empty list for non-existent case-insensitive directories',
() {
expect(Glob('non/existent/**', caseSensitive: false).listSync(), []);
expect(
Glob('non/existent/**', caseSensitive: false).listSync(), <Never>[]);
});
});

group('when case-sensitive', () {
test('lists literals case-sensitively', () {
expect(Glob('foo/BAZ/qux', caseSensitive: true).listSync(), []);
expect(Glob('foo/BAZ/qux', caseSensitive: true).listSync(), <Never>[]);
});

test('lists ranges case-sensitively', () {
expect(Glob('foo/[BX][A-Z]z/qux', caseSensitive: true).listSync(), []);
expect(Glob('foo/[BX][A-Z]z/qux', caseSensitive: true).listSync(),
<Never>[]);
});

test('options preserve case-sensitivity', () {
expect(Glob('foo/{BAZ,ZAP}/qux', caseSensitive: true).listSync(), []);
expect(
Glob('foo/{BAZ,ZAP}/qux', caseSensitive: true).listSync(), <Never>[]);
});
});

Expand Down Expand Up @@ -317,7 +321,7 @@ typedef ListFn = FutureOr<List<String>> Function(String glob,
{bool recursive, bool followLinks, bool? caseSensitive});

/// Runs [callback] in two groups with two values of [listFn]: one that uses
/// [Glob.list], one that uses [Glob.listSync].
/// `Glob.list`, one that uses `Glob.listSync`.
void syncAndAsync(FutureOr Function(ListFn) callback) {
group('async', () {
callback((pattern, {recursive = false, followLinks = true, caseSensitive}) {
Expand Down

0 comments on commit 379d60c

Please sign in to comment.