-
Notifications
You must be signed in to change notification settings - Fork 12
Differentially test linear-time regexp support for migrated shells #2457
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
Closed
Closed
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
19cb3d1
Differentially test linear-time regexp support for CMD
ericcornelissen 5b96d8d
Differentially test linear-time regexp support for Bash
ericcornelissen b058ad2
Differentially test linear-time regexp support for no shell
ericcornelissen 972ec23
Differentially test linear-time regexp support for BusyBox
ericcornelissen 53b8f6e
Differentially test linear-time regexp support for Csh
ericcornelissen e7d5622
Fix quote-escape order in differential tests
ericcornelissen 19cbf95
Refine differential testing for `csh.js`
ericcornelissen 7ec63a0
Merge branch 'main' into differential-lregexp-testing
ericcornelissen 18cfb19
Merge branch 'main' into differential-lregexp-testing
ericcornelissen 3739639
Differentially test linear-time regexp support for PowerShell
ericcornelissen 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,26 @@ | ||
| diff --git a/src/internal/unix/bash.js b/src/internal/unix/bash.js | ||
| index 19fba6d..c1c57ce 100644 | ||
| --- a/src/internal/unix/bash.js | ||
| +++ b/src/internal/unix/bash.js | ||
| @@ -15,7 +15,7 @@ function escapeArg(arg) { | ||
| .replace(/\n/gu, " ") | ||
| .replace(/\\/gu, "\\\\") | ||
| .replace(/(?<=^|\s)([#~])/gu, "\\$1") | ||
| - .replace(/(["$&'()*;<>?`{|])/gu, "\\$1") | ||
| + .replace(/(["$&'()*;<>?`{|[\]])/gu, "\\$1") | ||
| .replace(/(?<=[:=])(~)(?=[\s+\-/0:=]|$)/gu, "\\$1") | ||
| .replace(/([\t ])/gu, "\\$1"); | ||
| } | ||
| diff --git a/src/internal/unix/busybox.js b/src/internal/unix/busybox.js | ||
| index e61262f..0c91dc4 100644 | ||
| --- a/src/internal/unix/busybox.js | ||
| +++ b/src/internal/unix/busybox.js | ||
| @@ -15,7 +15,7 @@ function escapeArg(arg) { | ||
| .replace(/\n/gu, " ") | ||
| .replace(/\\/gu, "\\\\") | ||
| .replace(/(?<=^|\s)([#~])/gu, "\\$1") | ||
| - .replace(/(["$&'()*;<>?`|])/gu, "\\$1") | ||
| + .replace(/(["$&'()*;<>?`|[\]])/gu, "\\$1") | ||
| .replace(/([\t ])/gu, "\\$1"); | ||
| } | ||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
| /** | ||
| * @overview Contains (additional) unit tests for the escaping functionality for | ||
| * the Bourne-again shell (Bash). | ||
| * @license MIT | ||
| */ | ||
|
|
||
| import { testProp } from "@fast-check/ava"; | ||
| import * as fc from "fast-check"; | ||
|
|
||
| import * as old from "../../../node_modules/shescape-previous/src/internal/unix/bash.js"; | ||
| import * as upd from "../../../src/internal/unix/bash.js"; | ||
|
|
||
| const numRuns = 5_000_000; | ||
|
|
||
| testProp( | ||
| "escape functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getEscapeFunction(); | ||
| const oldFn = old.getEscapeFunction(); | ||
|
|
||
| const got = updFn(arg).replace(/(?<=[:=])(\\~)(?!\\?[\s+\-/0:=]|$)/gu, "~"); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "quote functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getQuoteFunction(); | ||
| const oldFn = old.getQuoteFunction(); | ||
|
|
||
| const got = updFn[0](updFn[1](arg)); | ||
| const want = oldFn[0](oldFn[1](arg)); | ||
ericcornelissen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "flag protection functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getFlagProtectionFunction(); | ||
| const oldFn = old.getFlagProtectionFunction(); | ||
|
|
||
| const got = updFn(arg); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
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,55 @@ | ||
| /** | ||
| * @overview Contains (additional) unit tests for the escaping functionality for | ||
| * the BusyBox shell. | ||
| * @license MIT | ||
| */ | ||
|
|
||
| import { testProp } from "@fast-check/ava"; | ||
| import * as fc from "fast-check"; | ||
|
|
||
| import * as old from "../../../node_modules/shescape-previous/src/internal/unix/busybox.js"; | ||
| import * as upd from "../../../src/internal/unix/busybox.js"; | ||
|
|
||
| const numRuns = 5_000_000; | ||
|
|
||
| testProp( | ||
| "escape functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getEscapeFunction(); | ||
| const oldFn = old.getEscapeFunction(); | ||
|
|
||
| const got = updFn(arg); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "quote functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getQuoteFunction(); | ||
| const oldFn = old.getQuoteFunction(); | ||
|
|
||
| const got = updFn[0](updFn[1](arg)); | ||
| const want = oldFn[0](oldFn[1](arg)); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "flag protection functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getFlagProtectionFunction(); | ||
| const oldFn = old.getFlagProtectionFunction(); | ||
|
|
||
| const got = updFn(arg); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * @overview Contains (additional) unit tests for the escaping functionality for | ||
| * the the Windows Command Prompt. | ||
| * @license MIT | ||
| */ | ||
|
|
||
| import { testProp } from "@fast-check/ava"; | ||
| import * as fc from "fast-check"; | ||
|
|
||
| import * as old from "../../../node_modules/shescape-previous/src/internal/win/cmd.js"; | ||
| import * as upd from "../../../src/internal/win/cmd.js"; | ||
|
|
||
| const numRuns = 5_000_000; | ||
|
|
||
| testProp( | ||
| "escape functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getEscapeFunction(); | ||
| const oldFn = old.getEscapeFunction(); | ||
|
|
||
| const got = updFn(arg); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "quote functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getQuoteFunction(); | ||
| const oldFn = old.getQuoteFunction(); | ||
|
|
||
| const got = updFn[0](updFn[1](arg)); | ||
| const want = oldFn[0](oldFn[1](arg)); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); | ||
|
|
||
| testProp( | ||
| "flag protection functionality is unchanged", | ||
| [fc.string()], | ||
| (t, arg) => { | ||
| const updFn = upd.getFlagProtectionFunction(); | ||
| const oldFn = old.getFlagProtectionFunction(); | ||
|
|
||
| const got = updFn(arg); | ||
| const want = oldFn(arg); | ||
| t.is(got, want); | ||
| }, | ||
| { numRuns }, | ||
| ); |
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.
Uh oh!
There was an error while loading. Please reload this page.