Skip to content

Commit a22f4d3

Browse files
sigurdmCommit Queue
authored andcommitted
Hide remote run behind flag (until aligned)
Prevent introducing a breaking change later by removing the current incantation of remote run before it goes into stable. See: #62123 for details. Change-Id: I53e0ba84a9317bd16d1249d2bcf1b07a0467a49d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467021 Commit-Queue: Sigurd Meldgaard <[email protected]> Reviewed-by: Jonas Jensen <[email protected]>
1 parent 04753f6 commit a22f4d3

File tree

4 files changed

+104
-90
lines changed

4 files changed

+104
-90
lines changed

pkg/dartdev/lib/src/commands/run.dart

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,17 @@ class RunCommand extends DartdevCommand {
5858
this.dataAssetsExperimentEnabled = false,
5959
}) : super(
6060
cmdName,
61-
'''Run a Dart program from a file, a local package, or a remote package.
61+
'''Run a Dart program from a file or a local package.
6262
63-
Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]
63+
Usage: dart [vm-options] run [arguments] <dart-file>|<local-package> [args]
6464
6565
<dart-file>
6666
A path to a Dart script (e.g., `bin/main.dart`).
6767
6868
<local-package>
6969
An executable from a local package dependency, in the format <package>[:<executable>].
7070
For example, `test:test` runs the `test` executable from the `test` package.
71-
If the executable is not specified, the package name is used.
72-
73-
<remote-executable>
74-
An executable from a remote package. This can be from a hosted package server
75-
(like pub.dev) or a git repository.
76-
77-
When running a remote executable, all other command-line flags are disabled,
78-
except for the options for remote executables. `dart run <remote-executable>`
79-
uses `dart install` under the hood and compiles the app into a standalone
80-
executable, preventing passing VM options.
81-
82-
From a hosted package server:
83-
<hosted-url>/<package>[@<version>][:<executable>]
84-
85-
Downloads the package from a hosted package server and runs the specified
86-
executable.
87-
If a version is provided, the specified version is downloaded.
88-
If an executable is not specified, the package name is used.
89-
For example, `https://pub.dev/[email protected]:dcli_complete` runs the
90-
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
91-
92-
From a git repository:
93-
<git-url>[:<executable>]
94-
95-
Clones the git repository and runs the specified executable from it.
96-
If an executable is not specified, the package name from the cloned
97-
repository's pubspec.yaml is used.
98-
The git url can be any valid git url.''',
71+
If the executable is not specified, the package name is used.''',
9972
verbose,
10073
) {
10174
argParser
@@ -344,13 +317,46 @@ Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-ex
344317
hide: true,
345318
)
346319
..addExperimentalFlags(verbose: verbose)
347-
..addSeparator('Options for remote executables:')
320+
..addFlag(
321+
'enable-experiment-remote-run',
322+
negatable: false,
323+
hide: !verbose,
324+
help: '''
325+
Enables running executables from remote packages.
326+
327+
When running a remote executable, all other command-line flags are disabled,
328+
except for the options for remote executables. `dart run <remote-executable>`
329+
uses `dart install` under the hood and compiles the app into a standalone
330+
executable, preventing passing VM options.
331+
332+
(Syntax is expected to change in the future.)
333+
334+
From a hosted package server:
335+
<hosted-url>/<package>[@<version>][:<executable>]
336+
337+
Downloads the package from a hosted package server and runs the specified
338+
executable.
339+
If a version is provided, the specified version is downloaded.
340+
If an executable is not specified, the package name is used.
341+
For example, `https://pub.dev/[email protected]:dcli_complete` runs the
342+
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
343+
344+
From a git repository:
345+
<git-url>[:<executable>]
346+
347+
Clones the git repository and runs the specified executable from it.
348+
If an executable is not specified, the package name from the cloned
349+
repository's pubspec.yaml is used.
350+
The git url can be any valid git url.''',
351+
)
348352
..addOption(
353+
hide: !verbose,
349354
gitPathOption,
350355
help: 'Path of git package in repository. '
351356
'Only applies when using a git url for <remote-executable>.',
352357
)
353358
..addOption(
359+
hide: !verbose,
354360
gitRefOption,
355361
help: 'Git branch or commit to be retrieved. '
356362
'Only applies when using a git url for <remote-executable>.',
@@ -443,7 +449,8 @@ Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-ex
443449
runArgs = args.rest.skip(1).toList();
444450
}
445451

446-
if (_isRemoteRun(mainCommand)) {
452+
if (args.flag('enable-experiment-remote-run') &&
453+
_isRemoteRun(mainCommand)) {
447454
return _runRemote(args, mainCommand, runArgs);
448455
}
449456
return _runLocal(args, mainCommand, runArgs);
@@ -665,7 +672,8 @@ Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-ex
665672
if (argResults.wasParsed(option) &&
666673
option != gitPathOption &&
667674
option != gitRefOption &&
668-
option != verbosityOption) {
675+
option != verbosityOption &&
676+
option != 'enable-experiment-remote-run') {
669677
usageException(
670678
'Option $option cannot be used in remote runs. '
671679
'`dart run <remote-executable>` uses `dart install` under the hood '

pkg/dartdev/test/commands/help_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Project
8989
compile Compile Dart to various formats.
9090
create Create a new Dart project.
9191
pub Work with packages.
92-
run Run a Dart program from a file, a local package, or a remote package.
92+
run Run a Dart program from a file or a local package.
9393
test Run tests for a project.
9494
9595
Source code

pkg/dartdev/test/commands/run_test.dart

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,13 @@ void run() {
104104
p = project();
105105
var result = await p.run(['run', '--help']);
106106

107-
expect(
108-
result.stdout,
109-
contains(
110-
'Run a Dart program from a file, a local package, or a remote package.'));
107+
expect(result.stdout,
108+
contains('Run a Dart program from a file or a local package.'));
111109
expect(result.stdout, contains('Debugging options:'));
112110
expect(
113111
result.stdout,
114112
contains(
115-
'Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]',
113+
'Usage: dart [vm-options] run [arguments] <dart-file>|<local-package> [args]',
116114
),
117115
);
118116
expect(result.stderr, isEmpty);
@@ -123,15 +121,13 @@ void run() {
123121
p = project();
124122
var result = await p.run(['run', '--help', '--verbose']);
125123

126-
expect(
127-
result.stdout,
128-
contains(
129-
'Run a Dart program from a file, a local package, or a remote package.'));
124+
expect(result.stdout,
125+
contains('Run a Dart program from a file or a local package.'));
130126
expect(result.stdout, contains('Debugging options:'));
131127
expect(
132128
result.stdout,
133129
contains(
134-
'Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]',
130+
'Usage: dart [vm-options] run [arguments] <dart-file>|<local-package> [args]',
135131
),
136132
);
137133
expect(result.stderr, isEmpty);

pkg/dartdev/test/native_assets/run_remote_test.dart

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -48,52 +48,43 @@ void main() async {
4848
final result = await _runDartdev(
4949
fromDartdevSource,
5050
'run',
51-
['--help'],
51+
['--help', '-v'],
5252
null,
5353
{},
5454
);
55+
print(result.stdout);
5556
expect(
5657
result.stdout,
57-
stringContainsInOrder(
58-
[
59-
'''Run a Dart program from a file, a local package, or a remote package.
60-
61-
Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]
62-
''',
63-
'''
64-
<remote-executable>
65-
An executable from a remote package. This can be from a hosted package server
66-
(like pub.dev) or a git repository.
67-
68-
When running a remote executable, all other command-line flags are disabled,
69-
except for the options for remote executables. `dart run <remote-executable>`
70-
uses `dart install` under the hood and compiles the app into a standalone
71-
executable, preventing passing VM options.
72-
73-
From a hosted package server:
74-
<hosted-url>/<package>[@<version>][:<executable>]
75-
76-
Downloads the package from a hosted package server and runs the specified
77-
executable.
78-
If a version is provided, the specified version is downloaded.
79-
If an executable is not specified, the package name is used.
80-
For example, `https://pub.dev/[email protected]:dcli_complete` runs the
81-
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
82-
83-
From a git repository:
84-
<git-url>[:<executable>]
85-
86-
Clones the git repository and runs the specified executable from it.
87-
If an executable is not specified, the package name from the cloned
88-
repository's pubspec.yaml is used.
89-
The git url can be any valid git url.
90-
''',
91-
'''
92-
Options for remote executables:
93-
--git-path Path of git package in repository. Only applies when using a git url for <remote-executable>.
94-
--git-ref Git branch or commit to be retrieved. Only applies when using a git url for <remote-executable>.
95-
'''
96-
],
58+
contains(
59+
'''
60+
--enable-experiment-remote-run Enables running executables from remote packages.
61+
62+
When running a remote executable, all other command-line flags are disabled,
63+
except for the options for remote executables. `dart run <remote-executable>`
64+
uses `dart install` under the hood and compiles the app into a standalone
65+
executable, preventing passing VM options.
66+
67+
(Syntax is expected to change in the future.)
68+
69+
From a hosted package server:
70+
<hosted-url>/<package>[@<version>][:<executable>]
71+
72+
Downloads the package from a hosted package server and runs the specified
73+
executable.
74+
If a version is provided, the specified version is downloaded.
75+
If an executable is not specified, the package name is used.
76+
For example, `https://pub.dev/[email protected]:dcli_complete` runs the
77+
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
78+
79+
From a git repository:
80+
<git-url>[:<executable>]
81+
82+
Clones the git repository and runs the specified executable from it.
83+
If an executable is not specified, the package name from the cloned
84+
repository's pubspec.yaml is used.
85+
The git url can be any valid git url.
86+
--git-path Path of git package in repository. Only applies when using a git url for <remote-executable>.
87+
--git-ref Git branch or commit to be retrieved. Only applies when using a git url for <remote-executable>.''',
9788
),
9889
);
9990
});
@@ -117,6 +108,7 @@ Options for remote executables:
117108
fromDartdevSource,
118109
'run',
119110
[
111+
'--enable-experiment-remote-run',
120112
'https://pub.dev/$_packageForTest$version:$_cliToolForTest',
121113
// Make sure to pass arguments that influence stdout.
122114
'compare',
@@ -153,6 +145,7 @@ Options for remote executables:
153145
final (gitUri, gitRef) = await _setupSimpleGitRepo(tempUri);
154146
final gitPath = './';
155147
final arguments = [
148+
'--enable-experiment-remote-run',
156149
if (testArguments.contains('--git-path')) ...[
157150
'--git-path',
158151
gitPath,
@@ -199,22 +192,34 @@ Options for remote executables:
199192

200193
final errorArgumentss = [
201194
(
202-
['https://pub.dev/this_package_does_not_exist_12345'],
195+
[
196+
'--enable-experiment-remote-run',
197+
'https://pub.dev/this_package_does_not_exist_12345'
198+
],
203199
'could not find package this_package_does_not_exist_12345 at',
204200
errorExitCode,
205201
),
206202
(
207-
['--git-path', 'foo/', 'https://pub.dev/vm_snapshot_analysis'],
203+
[
204+
'--enable-experiment-remote-run',
205+
'--git-path',
206+
'foo/',
207+
'https://pub.dev/vm_snapshot_analysis'
208+
],
208209
'git-path',
209210
usageExitCode,
210211
),
211212
(
212-
['--enable-asserts', 'https://pub.dev/vm_snapshot_analysis'],
213+
[
214+
'--enable-experiment-remote-run',
215+
'--enable-asserts',
216+
'https://pub.dev/vm_snapshot_analysis'
217+
],
213218
'enable-asserts',
214219
usageExitCode,
215220
),
216221
(
217-
['--git-path', 'foo/'],
222+
['--enable-experiment-remote-run', '--git-path', 'foo/'],
218223
'git-path',
219224
usageExitCode,
220225
),
@@ -292,7 +297,10 @@ void main(List<String> args) async {
292297
final runResult = await _runDartdev(
293298
fromDartdevSource,
294299
'run',
295-
['${gitUri.toFilePath()}:$packageName'],
300+
[
301+
'--enable-experiment-remote-run',
302+
'${gitUri.toFilePath()}:$packageName'
303+
],
296304
null,
297305
environment,
298306
expectedExitCode: errorExitCode,
@@ -309,6 +317,7 @@ void main(List<String> args) async {
309317
final (gitUri, gitRef) = await _setupSimpleGitRepo(tempUri);
310318

311319
final arguments = [
320+
'--enable-experiment-remote-run',
312321
'--git-ref',
313322
gitRef,
314323
'${gitUri.toFilePath()}:$_gitPackageForTest',
@@ -368,6 +377,7 @@ void main(List<String> args) async {
368377
);
369378

370379
final arguments = [
380+
'--enable-experiment-remote-run',
371381
if (verbosityError) '--verbosity=error',
372382
'--git-ref',
373383
gitRef,

0 commit comments

Comments
 (0)