Skip to content

Commit

Permalink
gulp babel-plugin-test failure should fail ci (#29998)
Browse files Browse the repository at this point in the history
* gulp babel-plugin-test failure should fail ci

* fix tests

* point to the type
  • Loading branch information
samouri committed Aug 27, 2020
1 parent 2e33d04 commit 1a921b9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
Expand Up @@ -41,9 +41,8 @@ function defaultCalleeToPropertiesMap() {
}

// This Babel Plugin removes
// 1. `dev().info(...)`
// 2. `dev().fine(...)`
// 3. `user().fine(...)`
// - `dev().(info|fine|warn)(...)`
// - `user().(info|fine|warn)(...)`
// CallExpressions for production ESM builds.
module.exports = function () {
let calleeToPropertiesMap = defaultCalleeToPropertiesMap();
Expand Down
Expand Up @@ -34,7 +34,8 @@ function hello() {
);
dev().fine(TAG, 'fine');
user().fine(TAG, 'fine');
user().info('Should not be removed');
user().info('Should be removed');
user().error('Should not be removed');
return false;
}

Expand All @@ -45,8 +46,8 @@ export function helloAgain() {
fromLocation.search
);
dev().fine(TAG, 'fine');
user().fine(TAG, 'fine');
user().info('Should not be removed');
user().warn(TAG, 'warn');
user().error('Should not be removed');
return false;
}

Expand All @@ -59,6 +60,7 @@ class Foo {
);
dev().fine(TAG, 'fine');
user().fine(TAG, 'fine');
user().info('Should not be removed');
dev().error(TAG, 'Should not be removed');
user().error('Should not be removed');
}
}
Expand Up @@ -16,21 +16,21 @@
import { dev, user } from '../../../../../../../src/log';
dev().info;
user().fine;
user().info('Should not be removed');

function hello() {
user().info('Should not be removed');
user().error('Should not be removed');
return false;
}

export function helloAgain() {
user().info('Should not be removed');
user().error('Should not be removed');
return false;
}

class Foo {
method() {
user().info('Should not be removed');
dev().error(TAG, 'Should not be removed');
user().error('Should not be removed');
}

}
Expand Up @@ -18,23 +18,23 @@ import {user} from '../../../../../../../src/log';

user().fine(TAG, 'fine');
user().fine;
user().info('Should not be removed');
user().error('Should not be removed');

function hello() {
user().fine(TAG, 'fine');
user().info('Should not be removed');
user().info('Should be removed');
return false;
}

export function helloAgain() {
user().fine(TAG, 'fine');
user().info('Should not be removed');
user().error('Should not be removed');
return false;
}

class Foo {
method() {
user().fine(TAG, 'fine');
user().info('Should not be removed');
user().info('Should be removed');
}
}
Expand Up @@ -15,21 +15,18 @@
*/
import { user } from '../../../../../../../src/log';
user().fine;
user().info('Should not be removed');
user().error('Should not be removed');

function hello() {
user().info('Should not be removed');
return false;
}

export function helloAgain() {
user().info('Should not be removed');
user().error('Should not be removed');
return false;
}

class Foo {
method() {
user().info('Should not be removed');
}
method() {}

}
8 changes: 7 additions & 1 deletion build-system/tasks/babel-plugin-tests.js
Expand Up @@ -35,7 +35,13 @@ async function babelPluginTests() {
testRegex: '/babel-plugins/[^/]+/test/.+\\.m?js$',
transformIgnorePatterns: ['/node_modules/'],
};
await jest.runCLI(options, projects);

// The `jest.runCLI` command is undocumented. See the types file for object shape:
// https://github.com/facebook/jest/blob/bd76829f66c5c0f3c6907b80010f19893cb0fc8c/packages/jest-test-result/src/types.ts#L74-L91.
const aggregatedResults = await jest.runCLI(options, projects);
if (!aggregatedResults.results.success) {
throw new Error('See the logs above for details.');
}
}

module.exports = {
Expand Down

0 comments on commit 1a921b9

Please sign in to comment.