Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track unfinished hook actions as regular errors
- Loading branch information
1 parent
511e9ae
commit c2638fe
Showing
15 changed files
with
173 additions
and
83 deletions.
There are no files selected for viewing
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,3 +1,8 @@ | ||
export function addUnresolvedAction(_actionTuple: [string, string, Parameters<any>]): void {} | ||
import { PluginDriver } from '../src/utils/PluginDriver'; | ||
|
||
export function resolveAction(_actionTuple: [string, string, Parameters<any>]): void {} | ||
export function catchUnfinishedHookActions<T>( | ||
_pluginDriver: PluginDriver, | ||
callback: () => Promise<T> | ||
): Promise<T> { | ||
return callback(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
const assert = require('assert'); | ||
const { assertIncludes } = require('../../../utils.js'); | ||
const { assertIncludes, assertDoesNotInclude } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'does not swallow errors on unfulfilled hooks actions', | ||
description: 'does not show unfulfilled hook actions if there are errors', | ||
minNodeVersion: 13, | ||
command: 'node build.mjs', | ||
after(err) { | ||
// exit code check has to be here as error(err) is only called upon failure | ||
assert.strictEqual(err && err.code, 1); | ||
}, | ||
error() { | ||
// do not abort test upon error | ||
return true; | ||
assert.strictEqual(err, null); | ||
}, | ||
stderr(stderr) { | ||
assertIncludes(stderr, '[!] Error: unfinished hook action(s) on exit'); | ||
assertIncludes(stderr, '(test) transform'); | ||
assertIncludes(stderr, 'Error: Error must be displayed.'); | ||
assertDoesNotInclude(stderr, 'Unfinished'); | ||
} | ||
}; |
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
20 changes: 20 additions & 0 deletions
20
test/cli/samples/unfulfilled-hook-actions-manual-exit/_config.js
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,20 @@ | ||
const assert = require('assert'); | ||
const { assertDoesNotInclude } = require('../../../utils'); | ||
const { assertIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: | ||
'does not show unfulfilled hook actions when exiting manually with a non-zero exit code', | ||
command: 'rollup -c --silent', | ||
after(err) { | ||
assert.strictEqual(err && err.code, 1); | ||
}, | ||
error() { | ||
// do not abort test upon error | ||
return true; | ||
}, | ||
stderr(stderr) { | ||
assertDoesNotInclude(stderr, 'Unfinished'); | ||
assertIncludes(stderr, 'Manual exit'); | ||
} | ||
}; |
Empty file.
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('a'); |
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('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 |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('c'); |
3 changes: 3 additions & 0 deletions
3
test/cli/samples/unfulfilled-hook-actions-manual-exit/index.js
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 @@ | ||
import './a.js'; | ||
import './b.js'; | ||
import './c.js'; |
29 changes: 29 additions & 0 deletions
29
test/cli/samples/unfulfilled-hook-actions-manual-exit/rollup.config.js
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,29 @@ | ||
const path = require('path'); | ||
|
||
let resolveA; | ||
const waitForA = new Promise(resolve => (resolveA = resolve)); | ||
|
||
module.exports = { | ||
input: './index.js', | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
transform(code, id) { | ||
if (id.endsWith('a.js')) { | ||
resolveA(); | ||
return new Promise(() => {}); | ||
} | ||
if (id.endsWith('b.js')) { | ||
return waitForA.then(() => { | ||
console.error('Manual exit'); | ||
process.exit(1); | ||
return new Promise(() => {}); | ||
}); | ||
} | ||
} | ||
} | ||
], | ||
output: { | ||
format: 'es' | ||
} | ||
}; |
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