Minor updates after merging 7.15.0 PRs (#13628)
This commit is contained in:
parent
70c66b3799
commit
fc3b09e533
@ -196,6 +196,26 @@ export function runCodeInTestContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function maybeMockConsole(validateLogs, run) {
|
||||||
|
const actualLogs = { stdout: "", stderr: "" };
|
||||||
|
|
||||||
|
if (!validateLogs) return { result: run(), actualLogs };
|
||||||
|
|
||||||
|
const spy1 = jest.spyOn(console, "log").mockImplementation(msg => {
|
||||||
|
actualLogs.stdout += `${msg}\n`;
|
||||||
|
});
|
||||||
|
const spy2 = jest.spyOn(console, "warn").mockImplementation(msg => {
|
||||||
|
actualLogs.stderr += `${msg}\n`;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
return { result: run(), actualLogs };
|
||||||
|
} finally {
|
||||||
|
spy1.mockRestore();
|
||||||
|
spy2.mockRestore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function run(task) {
|
function run(task) {
|
||||||
const {
|
const {
|
||||||
actual,
|
actual,
|
||||||
@ -234,7 +254,13 @@ function run(task) {
|
|||||||
if (execCode) {
|
if (execCode) {
|
||||||
const context = createContext();
|
const context = createContext();
|
||||||
const execOpts = getOpts(exec);
|
const execOpts = getOpts(exec);
|
||||||
result = babel.transform(execCode, execOpts);
|
|
||||||
|
// Ignore Babel logs of exec.js files.
|
||||||
|
// They will be validated in input/output files.
|
||||||
|
({ result } = maybeMockConsole(validateLogs, () =>
|
||||||
|
babel.transform(execCode, execOpts),
|
||||||
|
));
|
||||||
|
|
||||||
checkDuplicatedNodes(babel, result.ast);
|
checkDuplicatedNodes(babel, result.ast);
|
||||||
execCode = result.code;
|
execCode = result.code;
|
||||||
|
|
||||||
@ -251,24 +277,11 @@ function run(task) {
|
|||||||
const inputCode = actual.code;
|
const inputCode = actual.code;
|
||||||
const expectedCode = expected.code;
|
const expectedCode = expected.code;
|
||||||
if (!execCode || inputCode) {
|
if (!execCode || inputCode) {
|
||||||
const actualLogs = { stdout: "", stderr: "" };
|
let actualLogs;
|
||||||
let restoreSpies = null;
|
|
||||||
if (validateLogs) {
|
|
||||||
const spy1 = jest.spyOn(console, "log").mockImplementation(msg => {
|
|
||||||
actualLogs.stdout += `${msg}\n`;
|
|
||||||
});
|
|
||||||
const spy2 = jest.spyOn(console, "warn").mockImplementation(msg => {
|
|
||||||
actualLogs.stderr += `${msg}\n`;
|
|
||||||
});
|
|
||||||
restoreSpies = () => {
|
|
||||||
spy1.mockRestore();
|
|
||||||
spy2.mockRestore();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
result = babel.transform(inputCode, getOpts(actual));
|
({ result, actualLogs } = maybeMockConsole(validateLogs, () =>
|
||||||
|
babel.transform(inputCode, getOpts(actual)),
|
||||||
if (restoreSpies) restoreSpies();
|
));
|
||||||
|
|
||||||
const outputCode = normalizeOutput(result.code);
|
const outputCode = normalizeOutput(result.code);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.
|
||||||
1
packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/stderr.txt
vendored
Normal file
1
packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/stderr.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.
|
||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"validateLogs": true,
|
||||||
"plugins": [["proposal-pipeline-operator", { "proposal": "smart" }]]
|
"plugins": [["proposal-pipeline-operator", { "proposal": "smart" }]]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.
|
||||||
@ -1,3 +1 @@
|
|||||||
export declare enum A {}
|
export declare enum A {}
|
||||||
|
|
||||||
;
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
;
|
export {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user