Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure test after() callback is always executed #3936

Merged
merged 2 commits into from Jan 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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