-
Notifications
You must be signed in to change notification settings - Fork 231
Rename --checked to --check-asserts #1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,20 @@ import '../utils.dart'; | |
|
||
/// Handles the `run` pub command. | ||
class RunCommand extends PubCommand { | ||
String get name => "run"; | ||
String get description => "Run an executable from a package."; | ||
String get invocation => "pub run <executable> [args...]"; | ||
String get name => 'run'; | ||
String get description => 'Run an executable from a package.'; | ||
String get invocation => 'pub run <executable> [args...]'; | ||
bool get allowTrailingOptions => false; | ||
|
||
RunCommand() { | ||
argParser.addFlag("checked", | ||
abbr: "c", help: "Enable runtime type checks and assertions."); | ||
argParser.addOption("mode", help: "Deprecated option", hide: true); | ||
argParser.addFlag('enable-asserts', help: 'Enable assert statements.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
argParser.addFlag('checked', abbr: 'c', hide: true); | ||
argParser.addOption('mode', help: 'Deprecated option', hide: true); | ||
} | ||
|
||
Future run() async { | ||
if (argResults.rest.isEmpty) { | ||
usageException("Must specify an executable to run."); | ||
usageException('Must specify an executable to run.'); | ||
} | ||
|
||
var package = entrypoint.root.name; | ||
|
@@ -36,31 +36,31 @@ class RunCommand extends PubCommand { | |
|
||
// A command like "foo:bar" runs the "bar" script from the "foo" package. | ||
// If there is no colon prefix, default to the root package. | ||
if (executable.contains(":")) { | ||
var components = split1(executable, ":"); | ||
if (executable.contains(':')) { | ||
var components = split1(executable, ':'); | ||
package = components[0]; | ||
executable = components[1]; | ||
|
||
if (p.split(executable).length > 1) { | ||
usageException( | ||
"Cannot run an executable in a subdirectory of a dependency."); | ||
'Cannot run an executable in a subdirectory of a dependency.'); | ||
} | ||
} else if (onlyIdentifierRegExp.hasMatch(executable)) { | ||
// "pub run foo" means the same thing as "pub run foo:foo" as long as | ||
// "foo" is a valid Dart identifier (and thus package name). | ||
package = executable; | ||
} | ||
|
||
if (argResults.wasParsed("mode")) { | ||
log.warning("The --mode flag is deprecated and has no effect."); | ||
if (argResults.wasParsed('mode')) { | ||
log.warning('The --mode flag is deprecated and has no effect.'); | ||
} | ||
|
||
// The user may pass in an executable without an extension, but the file | ||
// to actually execute will always have one. | ||
if (p.extension(executable) != ".dart") executable += ".dart"; | ||
if (p.extension(executable) != '.dart') executable += '.dart'; | ||
|
||
var snapshotPath = p.join( | ||
entrypoint.cachePath, "bin", package, "$executable.snapshot.dart2"); | ||
entrypoint.cachePath, 'bin', package, '$executable.snapshot.dart2'); | ||
|
||
// Don't ever compile snapshots for mutable packages, since their code may | ||
// change later on. | ||
|
@@ -69,7 +69,7 @@ class RunCommand extends PubCommand { | |
!entrypoint.packageGraph.isPackageMutable(package)); | ||
|
||
var exitCode = await runExecutable(entrypoint, package, executable, args, | ||
checked: argResults['checked'], | ||
checked: argResults['enable-asserts'] || argResults['checked'], | ||
snapshotPath: useSnapshot ? snapshotPath : null, | ||
recompile: entrypoint.precompileExecutables); | ||
await flushThenExit(exitCode); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ import 'utils.dart'; | |
/// | ||
/// Arguments from [args] will be passed to the spawned Dart application. | ||
/// | ||
/// If [checked] is true, the program is run in checked mode. | ||
/// If [checked] is true, the program is run with assertions enabled. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and elsewhere: how about "with assertion checking enabled"? |
||
/// | ||
/// If [packagesFile] is passed, it's used as the package config file path for | ||
/// the executable. Otherwise, `entrypoint.packagesFile` is used. | ||
|
@@ -117,7 +117,7 @@ Future<String> _executablePath( | |
return p.absolute(fullPath); | ||
} | ||
|
||
/// Like [runSnapshot], but runs [recompile] if [path] doesn't exist yet. | ||
/// Like [_runSnapshot], but runs [recompile] if [path] doesn't exist yet. | ||
/// | ||
/// Returns `null` if [path] doesn't exist and isn't generated by [recompile]. | ||
Future<int> _runOrCompileSnapshot(String path, Iterable<String> args, | ||
|
@@ -130,7 +130,7 @@ Future<int> _runOrCompileSnapshot(String path, Iterable<String> args, | |
if (!fileExists(path)) return null; | ||
} | ||
|
||
return await runSnapshot(path, args, | ||
return await _runSnapshot(path, args, | ||
recompile: recompile, packagesFile: packagesFile, checked: checked); | ||
} | ||
|
||
|
@@ -141,12 +141,12 @@ Future<int> _runOrCompileSnapshot(String path, Iterable<String> args, | |
/// expected to regenerate a snapshot at [path], after which the snapshot will | ||
/// be re-run. | ||
/// | ||
/// If [checked] is set, runs the snapshot in checked mode. | ||
/// If [checked] is set, runs the snapshot with assertions enabled. | ||
/// | ||
/// Returns the snapshot's exit code. | ||
/// | ||
/// This doesn't do any validation of the snapshot's SDK version. | ||
Future<int> runSnapshot(String path, Iterable<String> args, | ||
Future<int> _runSnapshot(String path, Iterable<String> args, | ||
{Future<void> recompile(), | ||
String packagesFile, | ||
bool checked = false}) async { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following seems clearer / more accurate as help text: Enable runtime checks of assert statements. WDYT? /cc @kwalrath @kevmoo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took this directly from
dart --help
. If we want to change this I think we should do it in both places.