Skip to content

Commit 2fc488c

Browse files
authored
build: minor improvements to testing script (#18363)
* Currently the test script doesn't support doing something like `yarn test material/stepper`, instead we have to pass in `src/material/stepper` explicitly. These changes make it so that we don't have to pass in `src`, because it's easy to forget. * Makes it so we exit the process, rather than throw an error when a target isn't found. This makes it easier to locate the error message since there won't be a large stack trace moving it up.
1 parent 22d7cf6 commit 2fc488c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/run-component-tests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ shelljs.exec(`yarn -s ${bazelBinary} ${bazelAction} ${testLabels.join(' ')}`);
7676
function getBazelPackageOfComponentName(name) {
7777
// Before guessing any Bazel package, we test if the name contains the
7878
// package name already. If so, we just use that for Bazel package.
79-
const targetName = convertPathToBazelLabel(name);
79+
const targetName = convertPathToBazelLabel(name) ||
80+
convertPathToBazelLabel(path.join(packagesDir, name));
8081
if (targetName !== null) {
8182
return targetName;
8283
}
@@ -89,8 +90,9 @@ function getBazelPackageOfComponentName(name) {
8990
return guessTargetName;
9091
}
9192
}
92-
throw Error(chalk.red(`Could not find test target for specified component: ` +
93+
console.error(chalk.red(`Could not find test target for specified component: ` +
9394
`${chalk.yellow(name)}. Looked in packages: ${orderedGuessPackages.join(', ')}`));
95+
process.exit(1);
9496
}
9597

9698
/** Converts a path to a Bazel label. */

0 commit comments

Comments
 (0)