Skip to content

Commit

Permalink
Fix fast path check of ensureUpToDate (#4271)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm committed May 16, 2024
1 parent 89e386b commit 84895ca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
1 change: 1 addition & 0 deletions lib/src/entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ To update `$lockFilePath` run `$topLevelProgram pub get`$suffix without
for (var package in packageConfig.packages) {
final pubspecPath = p.normalize(
p.join(
rootDir,
'.dart_tool',
package.rootUri
// Important to use `toFilePath()` here rather than `path`, as it handles Url-decoding.
Expand Down
39 changes: 18 additions & 21 deletions test/embedding/get_executable_for_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Future<void> testGetExecutable(
}
switch (resolution) {
case ResolutionAttempt.fastPath:
expect(output, contains('[e] FINE: Package Config up to date.'));
expect(output, contains('[E] FINE: Package Config up to date.'));
case ResolutionAttempt.noResolution:
expect(output, isNot(contains('[e] FINE: Package Config up to date.')));
expect(output, isNot(contains('[E] FINE: Package Config up to date.')));
expect(output, isNot(contains('MSG : Resolving dependencies')));
case ResolutionAttempt.resolution:
expect(output, contains('MSG : Resolving dependencies'));
Expand Down Expand Up @@ -289,7 +289,7 @@ void testGetExecutableForCommand() {
'myapp.dart-3.1.2+3.snapshot',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
':myapp',
Expand All @@ -302,7 +302,7 @@ void testGetExecutableForCommand() {
'myapp.dart-3.1.2+3.snapshot',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
':tool',
Expand All @@ -315,7 +315,7 @@ void testGetExecutableForCommand() {
'tool.dart-3.1.2+3.snapshot',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo',
Expand All @@ -329,7 +329,7 @@ void testGetExecutableForCommand() {
'foo.dart',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo',
Expand All @@ -342,7 +342,7 @@ void testGetExecutableForCommand() {
'foo.dart-3.1.2+3.snapshot',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo:tool',
Expand All @@ -356,7 +356,7 @@ void testGetExecutableForCommand() {
'tool.dart',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo:tool',
Expand All @@ -369,7 +369,7 @@ void testGetExecutableForCommand() {
'tool.dart-3.1.2+3.snapshot',
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'unknown:tool',
Expand All @@ -378,7 +378,7 @@ void testGetExecutableForCommand() {
'Could not find package `unknown` or file `unknown:tool`',
),
issue: CommandResolutionIssue.packageNotFound,
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo:unknown',
Expand All @@ -387,7 +387,7 @@ void testGetExecutableForCommand() {
'Could not find `bin/unknown.dart` in package `foo`.',
),
issue: CommandResolutionIssue.noBinaryFound,
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'unknownTool',
Expand All @@ -396,7 +396,7 @@ void testGetExecutableForCommand() {
'Could not find package `unknownTool` or file `unknownTool`',
),
issue: CommandResolutionIssue.packageNotFound,
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'transitive',
Expand All @@ -410,7 +410,7 @@ void testGetExecutableForCommand() {
),
allowSnapshot: false,
packageConfig: p.join('.dart_tool', 'package_config.json'),
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
});

Expand Down Expand Up @@ -489,8 +489,7 @@ void testGetExecutableForCommand() {
),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
packageConfig: p.join('..', '..', '.dart_tool', 'package_config.json'),
// TODO(sigurdm): Should be fast-path
resolution: ResolutionAttempt.resolution,
resolution: ResolutionAttempt.fastPath,
);

await testGetExecutable(
Expand All @@ -507,8 +506,7 @@ void testGetExecutableForCommand() {
allowSnapshot: false,
packageConfig: p.join('..', '.dart_tool', 'package_config.json'),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
// TODO(sigurdm): Should be fast-path
resolution: ResolutionAttempt.resolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'b:tool',
Expand All @@ -524,7 +522,7 @@ void testGetExecutableForCommand() {
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
'foo',
Expand All @@ -539,7 +537,7 @@ void testGetExecutableForCommand() {
),
packageConfig: p.join('.dart_tool', 'package_config.json'),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
resolution: ResolutionAttempt.noResolution,
resolution: ResolutionAttempt.fastPath,
);
await testGetExecutable(
':tool',
Expand All @@ -555,8 +553,7 @@ void testGetExecutableForCommand() {
),
packageConfig: p.join('..', '..', '.dart_tool', 'package_config.json'),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
// TODO(sigurdm): Should be fast-path
resolution: ResolutionAttempt.resolution,
resolution: ResolutionAttempt.fastPath,
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ Got dependencies in `myapp/example`.

## Section 10
$ pub run -C myapp 'bin/app.dart'
Resolving dependencies in `myapp`...
Downloading packages...
Got dependencies in `myapp`.
Building package executable...
Built test_pkg:app.
Hi
Expand Down Expand Up @@ -158,9 +155,6 @@ $ pub uploader -C myapp add sigurdm@google.com

## Section 13
$ pub deps -C myapp
Resolving dependencies in `myapp`...
Downloading packages...
Got dependencies in `myapp`.
Dart SDK 3.1.2+3
test_pkg 1.0.0
└── foo 1.0.0
Expand Down

0 comments on commit 84895ca

Please sign in to comment.