@putout/test 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/processor/index.js +21 -3
- package/lib/test.js +8 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -100,6 +100,8 @@ test('remove usless variables: for-of', (t) => {
|
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
*☝️When input and output the same test fails. Use [`noTransform()`](#notransformfilename) for such cases.*
|
|
104
|
+
|
|
103
105
|
### `transformCode(input, output)`
|
|
104
106
|
|
|
105
107
|
Check transform of `input` -> `output` code:
|
|
@@ -372,6 +374,8 @@ test('test: eslint: transform', async ({process}) => {
|
|
|
372
374
|
});
|
|
373
375
|
```
|
|
374
376
|
|
|
377
|
+
*☝️When input and output the same test fails. Use [`noProcess()`](#noprocessfilename--overrides) for such cases.*
|
|
378
|
+
|
|
375
379
|
### `noProcess(filename [, overrides])`
|
|
376
380
|
|
|
377
381
|
Check that filename would not be processed.
|
package/lib/processor/index.js
CHANGED
|
@@ -32,7 +32,6 @@ const remove = async (a) => {
|
|
|
32
32
|
|
|
33
33
|
const read = async (a, b) => {
|
|
34
34
|
const read = global.readFile || readFile;
|
|
35
|
-
|
|
36
35
|
return await read(a, b);
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -44,6 +43,11 @@ const buildOptions = ({options, plugins, processors}) => ({
|
|
|
44
43
|
|
|
45
44
|
const addDot = (a) => a ? `.${a}` : '';
|
|
46
45
|
|
|
46
|
+
const fail = (t, message) => {
|
|
47
|
+
const {__putout_test_fail = t.fail} = global;
|
|
48
|
+
return __putout_test_fail(message);
|
|
49
|
+
};
|
|
50
|
+
|
|
47
51
|
module.exports._addDot = addDot;
|
|
48
52
|
|
|
49
53
|
module.exports.createTest = (dir, options) => {
|
|
@@ -56,10 +60,11 @@ module.exports.createTest = (dir, options) => {
|
|
|
56
60
|
|
|
57
61
|
const createProcess = (dir, options) => (operator) => async (filename, plugins, processors) => {
|
|
58
62
|
if (!isStr(filename))
|
|
59
|
-
return
|
|
63
|
+
return fail(operator, `Expected filename to be string!`);
|
|
60
64
|
|
|
61
65
|
const {
|
|
62
66
|
processedSource,
|
|
67
|
+
rawSource,
|
|
63
68
|
output,
|
|
64
69
|
} = await process(
|
|
65
70
|
filename,
|
|
@@ -74,6 +79,9 @@ const createProcess = (dir, options) => (operator) => async (filename, plugins,
|
|
|
74
79
|
if (isUpdate())
|
|
75
80
|
return operator.pass('fixtures updated');
|
|
76
81
|
|
|
82
|
+
if (rawSource === processedSource)
|
|
83
|
+
return fail(operator, `'input' === 'output', use 'noProcess()'`);
|
|
84
|
+
|
|
77
85
|
return operator.equal(processedSource, output, 'fixtures should equal');
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -114,7 +122,17 @@ const createComparePlaces = (dir, options) => (operator) => async (filename, exp
|
|
|
114
122
|
|
|
115
123
|
module.exports._createComparePlaces = createComparePlaces;
|
|
116
124
|
|
|
117
|
-
async function process(filename, dir,
|
|
125
|
+
async function process(filename, dir, config) {
|
|
126
|
+
let {extension} = config;
|
|
127
|
+
const {
|
|
128
|
+
printer,
|
|
129
|
+
processors,
|
|
130
|
+
plugins,
|
|
131
|
+
fix = true,
|
|
132
|
+
noChange = false,
|
|
133
|
+
processorRunners,
|
|
134
|
+
} = config;
|
|
135
|
+
|
|
118
136
|
extension = addDot(extname(filename).slice(1) || extension);
|
|
119
137
|
filename = basename(filename, String(extension));
|
|
120
138
|
|
package/lib/test.js
CHANGED
|
@@ -36,6 +36,11 @@ global.__putout_test_fs = {
|
|
|
36
36
|
const isUpdate = () => Boolean(Number(process.env.UPDATE));
|
|
37
37
|
const getPrinter = () => process.env.PUTOUT_PRINTER;
|
|
38
38
|
|
|
39
|
+
const fail = (t, message) => {
|
|
40
|
+
const {__putout_test_fail = t.fail} = global;
|
|
41
|
+
return __putout_test_fail(message);
|
|
42
|
+
};
|
|
43
|
+
|
|
39
44
|
const TS = {
|
|
40
45
|
ENABLED: true,
|
|
41
46
|
DISABLED: false,
|
|
@@ -344,6 +349,9 @@ const transform = currify((dir, options, t, name, transformed = null, addons = {
|
|
|
344
349
|
}],
|
|
345
350
|
});
|
|
346
351
|
|
|
352
|
+
if (input === code)
|
|
353
|
+
return fail(t, `'input' === 'output', use 'noTransform()'`);
|
|
354
|
+
|
|
347
355
|
if (isUpdate() && !isStr) {
|
|
348
356
|
writeFixture({
|
|
349
357
|
full,
|
|
@@ -553,7 +561,6 @@ const noReportWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
|
553
561
|
rmFixture(`${full}-fix`);
|
|
554
562
|
|
|
555
563
|
const rule = parseRule(options);
|
|
556
|
-
|
|
557
564
|
const rules = {
|
|
558
565
|
[rule]: ['on', ruleOptions],
|
|
559
566
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Test runner for 🐊Putout plugins ",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"@putout/plugin-remove-empty": "*",
|
|
67
67
|
"@putout/plugin-remove-unused-variables": "*",
|
|
68
68
|
"c8": "^9.0.0",
|
|
69
|
-
"eslint": "^9.0.0
|
|
70
|
-
"eslint-plugin-n": "^17.0.0
|
|
69
|
+
"eslint": "^9.0.0",
|
|
70
|
+
"eslint-plugin-n": "^17.0.0",
|
|
71
71
|
"eslint-plugin-putout": "^22.0.0",
|
|
72
72
|
"lerna": "^6.0.1",
|
|
73
73
|
"madrun": "^10.0.0",
|