Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken Windows CLI tests (#3249)
* Sanitize stderr before checking output * Refine batchWarnings and improve coverage * Improve coverage * Fix linting * Try to reduce test to prevent ordering issues * Test plugin warnings * Test broken sourcemap * Improve coverage * Improve coverage * Improve coverage, make non-deferred handlers immediate by default * Aggregate circular dependency warnings
- Loading branch information
1 parent
8f4f012
commit 4eccc99
Showing
74 changed files
with
635 additions
and
251 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
const assert = require('assert'); | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'custom (plugin generated) code frame taking priority over pos generated one', | ||
command: 'rollup -c', | ||
error: () => true, | ||
stderr: stderr => { | ||
assert.ok(/custom code frame/.test(stderr)); | ||
} | ||
stderr: stderr => | ||
assertStderrIncludes( | ||
stderr, | ||
'[!] (plugin at position 1) Error: My error.\n' + | ||
'main.js (1:5)\n' + | ||
'custom code frame\n' + | ||
'Error: My error.' | ||
) | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
const assert = require('assert'); | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'errors with custom (plugin generated) code frame', | ||
description: 'errors with plugin generated code frames also contain stack', | ||
command: 'rollup -c', | ||
error: () => true, | ||
stderr: stderr => { | ||
assert.ok(/custom code frame/.test(stderr)); | ||
assertStderrIncludes( | ||
stderr, | ||
'[!] (plugin at position 1) Error: My error.\n' + | ||
'main.js\ncustom code frame\nError: My error.\n' + | ||
' at Object.transform' | ||
); | ||
assertStderrIncludes(stderr, 'rollup.config.js:11:17'); | ||
} | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
const assert = require('assert'); | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'shows warning when multiple chunks empty', | ||
command: 'rollup -c', | ||
error: () => true, | ||
stderr: stderr => { | ||
assert.ok(stderr.includes('(!) Generated empty chunks\na, b')); | ||
} | ||
stderr: stderr => assertStderrIncludes(stderr, '(!) Generated empty chunks\na, b') | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
const assert = require('assert'); | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'shows warning when chunk empty', | ||
command: 'rollup -c', | ||
error: () => true, | ||
stderr: stderr => { | ||
assert.ok(stderr.includes('(!) Generated an empty chunk\nmain')); | ||
} | ||
stderr: stderr => assertStderrIncludes(stderr, '(!) Generated an empty chunk\nmain') | ||
}; |
This file contains 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,18 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'displays warnings for broken sourcemaps', | ||
command: 'rollup -c', | ||
stderr: stderr => { | ||
fs.unlinkSync(path.resolve(__dirname, 'bundle')); | ||
fs.unlinkSync(path.resolve(__dirname, 'bundle.map')); | ||
assertStderrIncludes( | ||
stderr, | ||
'(!) Broken sourcemap\n' + | ||
'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect\n' + | ||
"Plugins that transform code (such as 'test-plugin1', 'test-plugin2' and 'test-plugin3') should generate accompanying sourcemaps" | ||
); | ||
} | ||
}; |
This file contains 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 @@ | ||
console.log('main'); |
This file contains 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,28 @@ | ||
module.exports = { | ||
input: 'main.js', | ||
plugins: [ | ||
{ | ||
name: 'test-plugin1', | ||
transform(code) { | ||
return code + '/*1*/'; | ||
} | ||
}, | ||
{ | ||
name: 'test-plugin2', | ||
transform(code) { | ||
return code + '/*2*/'; | ||
} | ||
}, | ||
{ | ||
name: 'test-plugin3', | ||
transform(code) { | ||
return code + '/*3*/'; | ||
} | ||
} | ||
], | ||
output: { | ||
format: 'esm', | ||
file: 'bundle', | ||
sourcemap: true | ||
} | ||
}; |
This file contains 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,16 @@ | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'warns for multiple circular dependencies', | ||
command: 'rollup -c', | ||
stderr: stderr => | ||
assertStderrIncludes( | ||
stderr, | ||
'(!) Circular dependencies\n' + | ||
'main.js -> dep1.js -> main.js\n' + | ||
'main.js -> dep2.js -> main.js\n' + | ||
'main.js -> dep3.js -> main.js\n' + | ||
'...and 3 more\n' + | ||
'' | ||
) | ||
}; |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep1'); |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep2'); |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep3'); |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep5'); |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep5'); |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep6'); |
This file contains 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,7 @@ | ||
import './dep1.js'; | ||
import './dep2.js'; | ||
import './dep3.js'; | ||
import './dep4.js'; | ||
import './dep5.js'; | ||
import './dep6.js'; | ||
console.log('main'); |
This file contains 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,6 @@ | ||
module.exports = { | ||
input: 'main.js', | ||
output: { | ||
format: 'esm' | ||
} | ||
}; |
This file contains 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,8 @@ | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'warns for circular dependencies', | ||
command: 'rollup -c', | ||
stderr: stderr => | ||
assertStderrIncludes(stderr, '(!) Circular dependency\n' + 'main.js -> dep.js -> main.js\n') | ||
}; |
This file contains 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,2 @@ | ||
import './main.js'; | ||
console.log('dep'); |
This file contains 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,2 @@ | ||
import './dep.js'; | ||
console.log('main'); |
This file contains 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,6 @@ | ||
module.exports = { | ||
input: 'main.js', | ||
output: { | ||
format: 'esm' | ||
} | ||
}; |
This file contains 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,28 @@ | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'warns when eval is used multiple times', | ||
command: 'rollup -c', | ||
stderr: stderr => | ||
assertStderrIncludes( | ||
stderr, | ||
'(!) Use of eval is strongly discouraged\n' + | ||
'https://rollupjs.org/guide/en/#avoiding-eval\n' + | ||
'dep1.js\n' + | ||
'1: eval(\'console.log("Hello");\');\n' + | ||
' ^\n' + | ||
'dep2.js\n' + | ||
'1: eval(\'console.log("Hello");\');\n' + | ||
' ^\n' + | ||
'2: eval(\'console.log("Hello again");\');\n' + | ||
'...and 1 other occurrence\n' + | ||
'dep3.js\n' + | ||
'1: eval(\'console.log("Hello");\');\n' + | ||
' ^\n' + | ||
'2: eval(\'console.log("Hello again");\');\n' + | ||
'3: eval(\'console.log("Hello again and again");\');\n' + | ||
'...and 2 other occurrences\n' + | ||
'\n' + | ||
'...and 3 other files' | ||
) | ||
}; |
This file contains 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 @@ | ||
eval('console.log("Hello");'); |
This file contains 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,2 @@ | ||
eval('console.log("Hello");'); | ||
eval('console.log("Hello again");'); |
This file contains 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,3 @@ | ||
eval('console.log("Hello");'); | ||
eval('console.log("Hello again");'); | ||
eval('console.log("Hello again and again");'); |
This file contains 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 @@ | ||
eval('console.log("Hello");'); |
This file contains 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 @@ | ||
eval('console.log("Hello");'); |
This file contains 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,7 @@ | ||
import './dep1.js'; | ||
import './dep2.js'; | ||
import './dep3.js'; | ||
import './dep4.js'; | ||
import './dep5.js'; | ||
|
||
eval('foo'); |
This file contains 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,6 @@ | ||
module.exports = { | ||
input: 'main.js', | ||
output: { | ||
format: 'esm' | ||
} | ||
}; |
This file contains 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,15 @@ | ||
const { assertStderrIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'warns when eval is used', | ||
command: 'rollup -c', | ||
stderr: stderr => | ||
assertStderrIncludes( | ||
stderr, | ||
'(!) Use of eval is strongly discouraged\n' + | ||
'https://rollupjs.org/guide/en/#avoiding-eval\n' + | ||
'main.js\n' + | ||
"1: eval('foo');\n" + | ||
' ^' | ||
) | ||
}; |
This file contains 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 @@ | ||
eval('foo'); |
This file contains 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,6 @@ | ||
module.exports = { | ||
input: 'main.js', | ||
output: { | ||
format: 'esm' | ||
} | ||
}; |
Oops, something went wrong.