Skip to content

Commit

Permalink
Merge branch 'main' into merge-test_reflective_loader-package
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem authored Dec 12, 2024
2 parents 59d823e + b78c509 commit bea4a35
Show file tree
Hide file tree
Showing 80 changed files with 1,588 additions and 643 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/timing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:timing"
about: "Create a bug or file a feature request against package:timing."
labels: "package:timing"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/test_reflective_loader/**'

'package:timing':
- changed-files:
- any-glob-to-any-file: 'pkgs/timing/**'

'package:unified_analytics':
- changed-files:
- any-glob-to-any-file: 'pkgs/unified_analytics/**'
67 changes: 67 additions & 0 deletions .github/workflows/timing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: package:timing

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/timing.yaml'
- 'pkgs/timing/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/timing.yaml'
- 'pkgs/timing/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/timing/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [3.4, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
run: dart pub get
- run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev, 2.2.0
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.4, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
run: dart pub get
- run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ don't naturally belong to other topic monorepos (like
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
| [timing](pkgs/timing/) | A simple package for tracking the performance of synchronous and asynchronous actions. | [![package issues](https://img.shields.io/badge/package:timing-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atiming) | [![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing) |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |

## Publishing automation
Expand Down
2 changes: 2 additions & 0 deletions pkgs/file/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 7.0.2-wip

## 7.0.1

* Update the pubspec repository field to reflect the new package repository.
Expand Down
7 changes: 1 addition & 6 deletions pkgs/file/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
include: package:lints/recommended.yaml

analyzer:
errors:
# Allow having TODOs in the code
todo: ignore
include: package:dart_flutter_team_lints/analysis_options.yaml
4 changes: 2 additions & 2 deletions pkgs/file/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:file/memory.dart';

Future<void> main() async {
final FileSystem fs = MemoryFileSystem();
final Directory tmp = await fs.systemTempDirectory.createTemp('example_');
final File outputFile = tmp.childFile('output');
final tmp = await fs.systemTempDirectory.createTemp('example_');
final outputFile = tmp.childFile('output');
await outputFile.writeAsString('Hello world!');
print(outputFile.readAsStringSync());
}
2 changes: 2 additions & 0 deletions pkgs/file/lib/chroot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

/// A file system that provides a view into _another_ `FileSystem` via a path.
library;

export 'src/backends/chroot.dart';
2 changes: 2 additions & 0 deletions pkgs/file/lib/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

/// Core interfaces containing the abstract `FileSystem` interface definition
/// and all associated types used by `FileSystem`.
library;

export 'src/forwarding.dart';
export 'src/interface.dart';
2 changes: 2 additions & 0 deletions pkgs/file/lib/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

/// A local file system implementation. This relies on the use of `dart:io`
/// and is thus not suitable for use in the browser.
library;

export 'src/backends/local.dart';
2 changes: 2 additions & 0 deletions pkgs/file/lib/memory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

/// An implementation of `FileSystem` that exists entirely in memory with an
/// internal representation loosely based on the Filesystem Hierarchy Standard.
library;

export 'src/backends/memory.dart';
export 'src/backends/memory/operations.dart';
10 changes: 5 additions & 5 deletions pkgs/file/lib/src/backends/chroot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library file.src.backends.chroot;

import 'dart:convert';
import 'dart:typed_data';

import 'package:file/file.dart';
import 'package:file/src/common.dart' as common;
import 'package:file/src/io.dart' as io;
import 'package:path/path.dart' as p;

import '../common.dart' as common;
import '../forwarding.dart';
import '../interface.dart';
import '../io.dart' as io;

part 'chroot/chroot_directory.dart';
part 'chroot/chroot_file.dart';
part 'chroot/chroot_file_system.dart';
Expand Down
46 changes: 22 additions & 24 deletions pkgs/file/lib/src/backends/chroot/chroot_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of file.src.backends.chroot;
part of '../chroot.dart';

class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
with ForwardingDirectory<Directory>, common.DirectoryAddOnsMixin {
_ChrootDirectory(ChrootFileSystem fs, String path) : super(fs, path);
_ChrootDirectory(super.fs, super.path);

factory _ChrootDirectory.wrapped(
ChrootFileSystem fs,
Directory delegate, {
bool relative = false,
}) {
String localPath = fs._local(delegate.path, relative: relative);
var localPath = fs._local(delegate.path, relative: relative);
return _ChrootDirectory(fs, localPath);
}

Expand All @@ -32,7 +32,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
if (await fileSystem.type(path) != expectedType) {
throw common.notADirectory(path);
}
FileSystemEntityType type = await fileSystem.type(newPath);
var type = await fileSystem.type(newPath);
if (type != FileSystemEntityType.notFound) {
if (type != expectedType) {
throw common.notADirectory(newPath);
Expand All @@ -44,7 +44,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
throw common.directoryNotEmpty(newPath);
}
}
String target = await fileSystem.link(path).target();
var target = await fileSystem.link(path).target();
await fileSystem.link(path).delete();
await fileSystem.link(newPath).create(target);
return fileSystem.directory(newPath);
Expand All @@ -60,7 +60,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
if (fileSystem.typeSync(path) != expectedType) {
throw common.notADirectory(path);
}
FileSystemEntityType type = fileSystem.typeSync(newPath);
var type = fileSystem.typeSync(newPath);
if (type != FileSystemEntityType.notFound) {
if (type != expectedType) {
throw common.notADirectory(newPath);
Expand All @@ -72,7 +72,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
throw common.directoryNotEmpty(newPath);
}
}
String target = fileSystem.link(path).targetSync();
var target = fileSystem.link(path).targetSync();
fileSystem.link(path).deleteSync();
fileSystem.link(newPath).createSync(target);
return fileSystem.directory(newPath);
Expand All @@ -97,17 +97,15 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
@override
Future<Directory> create({bool recursive = false}) async {
if (_isLink) {
switch (await fileSystem.type(path)) {
case FileSystemEntityType.notFound:
throw common.noSuchFileOrDirectory(path);
case FileSystemEntityType.file:
throw common.fileExists(path);
case FileSystemEntityType.directory:
return switch (await fileSystem.type(path)) {
FileSystemEntityType.notFound =>
throw common.noSuchFileOrDirectory(path),
FileSystemEntityType.file => throw common.fileExists(path),
FileSystemEntityType.directory =>
// Nothing to do.
return this;
default:
throw AssertionError();
}
this,
_ => throw AssertionError()
};
} else {
return wrap(await delegate.create(recursive: recursive));
}
Expand Down Expand Up @@ -137,8 +135,8 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
bool recursive = false,
bool followLinks = true,
}) {
Directory delegate = this.delegate as Directory;
String dirname = delegate.path;
var delegate = this.delegate as Directory;
var dirname = delegate.path;
return delegate
.list(recursive: recursive, followLinks: followLinks)
.map((io.FileSystemEntity entity) => _denormalize(entity, dirname));
Expand All @@ -149,18 +147,18 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
bool recursive = false,
bool followLinks = true,
}) {
Directory delegate = this.delegate as Directory;
String dirname = delegate.path;
var delegate = this.delegate as Directory;
var dirname = delegate.path;
return delegate
.listSync(recursive: recursive, followLinks: followLinks)
.map((io.FileSystemEntity entity) => _denormalize(entity, dirname))
.toList();
}

FileSystemEntity _denormalize(io.FileSystemEntity entity, String dirname) {
p.Context ctx = fileSystem.path;
String relativePart = ctx.relative(entity.path, from: dirname);
String entityPath = ctx.join(path, relativePart);
var ctx = fileSystem.path;
var relativePart = ctx.relative(entity.path, from: dirname);
var entityPath = ctx.join(path, relativePart);
if (entity is io.File) {
return _ChrootFile(fileSystem, entityPath);
} else if (entity is io.Directory) {
Expand Down
10 changes: 5 additions & 5 deletions pkgs/file/lib/src/backends/chroot/chroot_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of file.src.backends.chroot;
part of '../chroot.dart';

typedef _SetupCallback = dynamic Function();

class _ChrootFile extends _ChrootFileSystemEntity<File, io.File>
with ForwardingFile {
_ChrootFile(ChrootFileSystem fs, String path) : super(fs, path);
_ChrootFile(super.fs, super.path);

factory _ChrootFile.wrapped(
ChrootFileSystem fs,
io.File delegate, {
bool relative = false,
}) {
String localPath = fs._local(delegate.path, relative: relative);
var localPath = fs._local(delegate.path, relative: relative);
return _ChrootFile(fs, localPath);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ class _ChrootFile extends _ChrootFileSystemEntity<File, io.File>

@override
Future<File> create({bool recursive = false, bool exclusive = false}) async {
String path = fileSystem._resolve(
var path = fileSystem._resolve(
this.path,
followLinks: false,
notFound: recursive ? _NotFoundBehavior.mkdir : _NotFoundBehavior.allow,
Expand Down Expand Up @@ -158,7 +158,7 @@ class _ChrootFile extends _ChrootFileSystemEntity<File, io.File>

@override
void createSync({bool recursive = false, bool exclusive = false}) {
String path = fileSystem._resolve(
var path = fileSystem._resolve(
this.path,
followLinks: false,
notFound: recursive ? _NotFoundBehavior.mkdir : _NotFoundBehavior.allow,
Expand Down
Loading

0 comments on commit bea4a35

Please sign in to comment.