From 40d1eba5b578d994c5d6be6371f7a8d25c7472d9 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Sat, 1 Feb 2020 17:05:31 +0100 Subject: [PATCH] build: minor improvements to testing script * 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. --- scripts/run-component-tests.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/run-component-tests.js b/scripts/run-component-tests.js index 85cf9ff0536b..d1ea22c16e0c 100644 --- a/scripts/run-component-tests.js +++ b/scripts/run-component-tests.js @@ -76,7 +76,8 @@ shelljs.exec(`yarn -s ${bazelBinary} ${bazelAction} ${testLabels.join(' ')}`); function getBazelPackageOfComponentName(name) { // Before guessing any Bazel package, we test if the name contains the // package name already. If so, we just use that for Bazel package. - const targetName = convertPathToBazelLabel(name); + const targetName = convertPathToBazelLabel(name) || + convertPathToBazelLabel(path.join(packagesDir, name)); if (targetName !== null) { return targetName; } @@ -89,8 +90,9 @@ function getBazelPackageOfComponentName(name) { return guessTargetName; } } - throw Error(chalk.red(`Could not find test target for specified component: ` + + console.error(chalk.red(`Could not find test target for specified component: ` + `${chalk.yellow(name)}. Looked in packages: ${orderedGuessPackages.join(', ')}`)); + process.exit(1); } /** Converts a path to a Bazel label. */