Skip to content

Commit 19cb3d1

Browse files
Differentially test linear-time regexp support for CMD
Create a unit test that differentially tests the change in CMD escaping from "normal" regular expression to linear-time-based regular expressions (in [1]). To do this properly, the `shescape-previous` version is downgraded to the version prior to this migration. [1]: 0f38a42
1 parent 3541df1 commit 19cb3d1

File tree

3 files changed

+61
-6
lines changed

3 files changed

+61
-6
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"prettier": "3.7.3",
9797
"publint": "0.3.18",
9898
"rollup": "4.60.0",
99-
"shescape-previous": "npm:shescape@2.1.10",
99+
"shescape-previous": "npm:shescape@2.1.8",
100100
"sinon": "21.0.3"
101101
},
102102
"scripts": {
@@ -139,7 +139,7 @@
139139
"mutation:unit": "stryker run config/stryker/unit.js",
140140
"mutation:integration": "npm run transpile && stryker run config/stryker/integration.js",
141141
"test": "npm-run-all test:*",
142-
"test:unit": "ava test/unit/**/*.test.js",
142+
"test:unit": "ava --timeout 59m test/unit/**/*.test.js",
143143
"test:integration": "npm run transpile && ava test/integration/**/*.test.js --timeout 2m",
144144
"test:e2e": "node script/busybox-sh.js && node script/double-link-sh.js && ava test/e2e/**/*.test.js --timeout 1m",
145145
"test:compat": "npm-run-all test:compat:*",

test/unit/win/differential.test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @overview Contains differential tests for the migration form standard regular
3+
* expressions to linear-time regular expressions in CMD.
4+
* @license MIT
5+
*/
6+
7+
import { testProp } from "@fast-check/ava";
8+
import * as fc from "fast-check";
9+
10+
import * as old from "../../../node_modules/shescape-previous/src/internal/win/cmd.js";
11+
import * as upd from "../../../src/internal/win/cmd.js";
12+
13+
const numRuns = 10_000_000;
14+
15+
testProp(
16+
"escape functionality is unchanged",
17+
[fc.string()],
18+
(t, arg) => {
19+
const updFn = upd.getEscapeFunction();
20+
const oldFn = old.getEscapeFunction();
21+
22+
const got = updFn(arg);
23+
const want = oldFn(arg);
24+
t.is(got, want);
25+
},
26+
{ numRuns },
27+
);
28+
29+
testProp(
30+
"quote functionality is unchanged",
31+
[fc.string()],
32+
(t, arg) => {
33+
const updFn = upd.getQuoteFunction();
34+
const oldFn = old.getQuoteFunction();
35+
36+
const got = updFn[0](updFn[1](arg));
37+
const want = oldFn[0](oldFn[1](arg));
38+
t.is(got, want);
39+
},
40+
{ numRuns },
41+
);
42+
43+
testProp(
44+
"flag protection functionality is unchanged",
45+
[fc.string()],
46+
(t, arg) => {
47+
const updFn = upd.getFlagProtectionFunction();
48+
const oldFn = old.getFlagProtectionFunction();
49+
50+
const got = updFn(arg);
51+
const want = oldFn(arg);
52+
t.is(got, want);
53+
},
54+
{ numRuns },
55+
);

0 commit comments

Comments
 (0)