Skip to content

Commit

Permalink
Ensure test after() callback is always executed (#3936)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
Benjamin-Dobell and lukastaegert committed Jan 26, 2021
1 parent 13489b9 commit 45d1ec2
Showing 1 changed file with 39 additions and 33 deletions.
72 changes: 39 additions & 33 deletions test/form/index.js
Expand Up @@ -15,42 +15,48 @@ runTestSuiteWithSamples('form', path.resolve(__dirname, 'samples'), (dir, config
let bundle;
const runRollupTest = async (inputFile, bundleFile, defaultFormat) => {
if (config.before) config.before();
process.chdir(dir);
bundle =
bundle ||
(await rollup.rollup(
try {
process.chdir(dir);
bundle =
bundle ||
(await rollup.rollup(
Object.assign(
{
input: dir + '/main.js',
onwarn: warning => {
if (
!(
config.expectedWarnings &&
config.expectedWarnings.indexOf(warning.code) >= 0
)
) {
throw new Error(
`Unexpected warnings (${warning.code}): ${warning.message}\n` +
'If you expect warnings, list their codes in config.expectedWarnings'
);
}
},
strictDeprecations: true
},
config.options || {}
)
));
await generateAndTestBundle(
bundle,
Object.assign(
{
input: dir + '/main.js',
onwarn: warning => {
if (
!(config.expectedWarnings && config.expectedWarnings.indexOf(warning.code) >= 0)
) {
throw new Error(
`Unexpected warnings (${warning.code}): ${warning.message}\n` +
'If you expect warnings, list their codes in config.expectedWarnings'
);
}
},
strictDeprecations: true
exports: 'auto',
file: inputFile,
format: defaultFormat
},
config.options || {}
)
));
await generateAndTestBundle(
bundle,
Object.assign(
{
exports: 'auto',
file: inputFile,
format: defaultFormat
},
(config.options || {}).output || {}
),
bundleFile,
config
);
if (config.after) config.after();
(config.options || {}).output || {}
),
bundleFile,
config
);
} finally {
if (config.after) config.after();
}
};

if (isSingleFormatTest) {
Expand Down

0 comments on commit 45d1ec2

Please sign in to comment.