-
Notifications
You must be signed in to change notification settings - Fork 42
add support to ignore ansi sequences when formatting usage display. Fixes #879 #942
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
Open
timmaffett
wants to merge
20
commits into
dart-lang:main
Choose a base branch
from
timmaffett:length_ignore_ansi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
02d4bf2
add support to ignore ansi sequences when formatting usage display
timmaffett 2fbb9e5
add support to ignore ansi sequences when formatting usage display
timmaffett 54238b7
Merge branch 'length_ignore_ansi' of github.com:timmaffett/core into …
timmaffett f7143f8
implement feedback and suggestions on PR
timmaffett 8b81b6f
changed regex to a more complete version covering entire ANSI/ECMA-48…
timmaffett e9744be
changed version number to 2.8.1
timmaffett 58df917
changed version number to 2.8.1
timmaffett 30a384d
Merge branch 'length_ignore_ansi' of github.com:timmaffett/core into …
timmaffett ecf598a
addressed @Irhn code review
timmaffett 0c6937b
fix test
timmaffett 17748b7
manual merge upsteam changes
timmaffett 28c84f8
Merge remote-tracking branch 'upstream/main' into length_ignore_ansi
timmaffett 14fdb72
dartfmt
natebosch 5389620
Replace quectocolors with io
natebosch 8a5d2d4
dart format
natebosch 9847144
Use a feature bump and -wip version
natebosch b599a4d
2.8.0 is not yet published
natebosch ba37f84
Reflow to 80 characters
natebosch 6bb74b4
Remove duplication in full test names and duplicated test cases
natebosch d7de9f6
local variable type annotation diagnostic
natebosch 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 |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | ||
| // 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. | ||
|
|
||
| /// This is an example of converting the args in test.dart to use this API. | ||
| /// It shows what it looks like to build an [ArgParser] and then, when the code | ||
| /// is run, demonstrates what the generated usage text looks like. | ||
| library; | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:args/args.dart'; | ||
| import 'package:io/ansi.dart'; | ||
|
|
||
| void main() { | ||
| var parser = ArgParser(); | ||
|
|
||
| parser.addSeparator('===== Platform'); | ||
|
|
||
| final javaScriptStyled = styleItalic.wrap(lightGreen.wrap('JavaScript')); | ||
|
|
||
| parser.addOption('compiler', | ||
| abbr: 'c', | ||
| defaultsTo: 'none', | ||
| help: blue.wrap('Specify any compilation step (if needed).'), | ||
| allowed: [ | ||
| 'none', | ||
| 'dart2js', | ||
| 'dartc' | ||
| ], | ||
| allowedHelp: { | ||
| 'none': | ||
| red.wrap('Do not compile the Dart code (run native Dart code on the' | ||
| ' VM).\n(only valid with the following runtimes: vm, drt)')!, | ||
| 'dart2js': green | ||
| .wrap('Compile dart code to $javaScriptStyled by running dart2js.\n' | ||
| '(only valid with the following runtimes: d8, drt, chrome\n' | ||
| 'safari, ie, firefox, opera, none (compile only))')!, | ||
| 'dartc': lightBlue | ||
| .wrap('Perform static analysis on Dart code by running dartc.\n' | ||
| '(only valid with the following runtimes: none)')!, | ||
| }); | ||
|
|
||
| parser.addOption('runtime', | ||
| abbr: 'r', | ||
| defaultsTo: 'vm', | ||
| help: magenta.wrap('Where the tests should be run.'), | ||
| allowed: [ | ||
| 'vm', | ||
| 'd8', | ||
| 'drt', | ||
| 'dartium', | ||
| 'ff', | ||
| 'firefox', | ||
| 'chrome', | ||
| 'safari', | ||
| 'ie', | ||
| 'opera', | ||
| 'none' | ||
| ], | ||
| allowedHelp: { | ||
| 'vm': cyan.wrap('Run Dart code on the standalone dart vm.')!, | ||
| 'd8': yellow | ||
| .wrap('Run $javaScriptStyled from the command line using v8.')!, | ||
| 'drt': lightGreen.wrap( | ||
| 'Run Dart or $javaScriptStyled in the headless version of Chrome,\n' | ||
| 'content shell.')!, | ||
| 'dartium': lightBlue.wrap('Run Dart or $javaScriptStyled in Dartium.')!, | ||
| 'ff': lightRed.wrap('Run $javaScriptStyled in Firefox')!, | ||
| 'chrome': yellow.wrap('Run $javaScriptStyled in Chrome')!, | ||
| 'safari': magenta.wrap('Run $javaScriptStyled in Safari')!, | ||
| 'ie': cyan.wrap('Run $javaScriptStyled in Internet Explorer')!, | ||
| 'opera': lightYellow.wrap('Run $javaScriptStyled in Opera')!, | ||
| 'none': darkGray.wrap( | ||
| 'No runtime, compile only (for example, used for dartc static\n' | ||
| 'analysis tests).')!, | ||
| }); | ||
|
|
||
| parser.addOption('arch', | ||
| abbr: 'a', | ||
| defaultsTo: 'ia32', | ||
| help: cyan.wrap('The architecture to run tests for'), | ||
| allowed: ['all', 'ia32', 'x64', 'simarm']); | ||
|
|
||
| parser.addOption('system', | ||
| abbr: 's', | ||
| defaultsTo: Platform.operatingSystem, | ||
| help: yellow.wrap('The operating system to run tests on'), | ||
| allowed: ['linux', 'macos', 'windows']); | ||
|
|
||
| parser.addSeparator('===== Runtime'); | ||
|
|
||
| parser.addOption('mode', | ||
| abbr: 'm', | ||
| defaultsTo: 'debug', | ||
| help: lightMagenta.wrap('Mode in which to run the tests'), | ||
| allowed: ['all', 'debug', 'release']); | ||
|
|
||
| parser.addFlag('checked', | ||
| defaultsTo: false, help: lightGreen.wrap('Run tests in checked mode')); | ||
|
|
||
| parser.addFlag('host-checked', | ||
| defaultsTo: false, help: red.wrap('Run compiler in checked mode')); | ||
|
|
||
| parser.addOption('timeout', | ||
| abbr: 't', help: white.wrap('Timeout in seconds')); | ||
|
|
||
| parser.addOption('tasks', | ||
| abbr: 'j', | ||
| defaultsTo: Platform.numberOfProcessors.toString(), | ||
| help: backgroundWhite | ||
| .wrap(blue.wrap('The number of parallel tasks to run'))); | ||
|
|
||
| parser.addOption('shards', | ||
| defaultsTo: '1', | ||
| help: green | ||
| .wrap('The number of instances that the tests will be sharded over')); | ||
|
|
||
| parser.addOption('shard', | ||
| defaultsTo: '1', | ||
| help: lightYellow | ||
| .wrap('The index of this instance when running in sharded mode')); | ||
|
|
||
| parser.addFlag('valgrind', | ||
| defaultsTo: false, help: lightRed.wrap('Run tests through valgrind')); | ||
|
|
||
| parser.addSeparator('===== Output'); | ||
|
|
||
| parser.addOption('progress', | ||
| abbr: 'p', | ||
| defaultsTo: 'compact', | ||
| help: lightBlue.wrap('Progress indication mode'), | ||
| allowed: [ | ||
| 'compact', | ||
| 'color', | ||
| 'line', | ||
| 'verbose', | ||
| 'silent', | ||
| 'status', | ||
| 'buildbot' | ||
| ]); | ||
|
|
||
| parser.addFlag('report', | ||
| defaultsTo: false, | ||
| help: lightMagenta.wrap( | ||
| 'Print a summary report of the number of tests, by expectation')); | ||
|
|
||
| parser.addFlag('verbose', | ||
| abbr: 'v', defaultsTo: false, help: red.wrap('Verbose output')); | ||
|
|
||
| parser.addFlag('list', | ||
| defaultsTo: false, help: blue.wrap('List tests only, do not run them')); | ||
|
|
||
| parser.addFlag('time', | ||
| help: green.wrap('Print timings information after running tests'), | ||
| defaultsTo: false); | ||
|
|
||
| parser.addFlag('batch', | ||
| abbr: 'b', | ||
| help: blue.wrap('Run browser tests in batch mode'), | ||
| defaultsTo: true); | ||
|
|
||
| parser.addSeparator('===== Miscellaneous'); | ||
|
|
||
| parser.addFlag('keep-generated-tests', | ||
| defaultsTo: false, | ||
| help: lightBlue | ||
| .wrap('Keep the generated files in the temporary directory')); | ||
|
|
||
| parser.addOption('special-command', help: lightMagenta.wrap(""" | ||
| Special command support. Wraps the command line in | ||
| a special command. The special command should contain | ||
| an '@' character which will be replaced by the normal | ||
| command. | ||
|
|
||
| For example if the normal command that will be executed | ||
| is 'dart file.dart' and you specify special command | ||
| 'python -u valgrind.py @ suffix' the final command will be | ||
| 'python -u valgrind.py dart file.dart suffix'""")); | ||
|
|
||
| parser.addOption('dart', help: yellow.wrap('Path to dart executable')); | ||
| parser.addOption('drt', | ||
| help: lightMagenta.wrap('Path to content shell executable')); | ||
| parser.addOption('dartium', | ||
| help: lightCyan.wrap('Path to Dartium Chrome executable')); | ||
| parser.addOption('mandatory', | ||
| help: magenta.wrap('A mandatory option'), mandatory: true); | ||
|
|
||
| print(parser.usage); | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
@lrhn - I'm inclined to make more of these implementation details private and remove the tests of the individual APIs, leaving only the tests for
lengthWithoutAnsiandpadWithoutAnsi. Do you have any concerns?