Skip to content

Commit

Permalink
feat(bazel): improve error output on intgeration test failure
Browse files Browse the repository at this point in the history
We should print the working directory of the test on failure, allowing
developers to quickly jump to the test directory on failure. Currently
this is hard to spot when the integration test produced a lot of output.
  • Loading branch information
devversion committed Apr 14, 2022
1 parent 9c74c6b commit 03acd84
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions bazel/integration/test_runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@
import * as fs from 'fs';
import * as path from 'path';
import * as tmp from 'tmp';
import {addWritePermissionFlag, writeExecutableFile} from './file_system_utils';
import {
PackageMappings,
readPackageJsonContents,
updateMappingsForPackageJson,
} from './package_json';

import {
BazelExpandedValue,
BazelFileInfo,
resolveBazelFile,
resolveBinaryWithRunfilesGracefully,
} from './bazel';
import {debug} from './debug';
import {
PackageMappings,
readPackageJsonContents,
updateMappingsForPackageJson,
} from './package_json';
import {addWritePermissionFlag, writeExecutableFile} from './file_system_utils';
import {
expandEnvironmentVariableSubstitutions,
getBinaryPassThroughScript,
prependToPathVariable,
runCommandInChildProcess,
} from './process_utils';

import {ENVIRONMENT_TMP_PLACEHOLDER} from './constants';
import {debug} from './debug';

/** Error class that is used when an integration command fails. */
class IntegrationTestCommandError extends Error {}

/**
* Test runner that takes a set of files within a Bazel package and copies the files
Expand Down Expand Up @@ -230,10 +235,11 @@ export class TestRunner {
);

if (!success) {
throw Error(
`Integration test command: \`${resolvedBinary} ${evaluatedArgs.join(' ')}\` failed. ` +
`See error output above for details.`,
);
console.error(`Command failed: \`${resolvedBinary} ${evaluatedArgs.join(' ')}\``);
console.error(`Command ran in test directory: ${path.normalize(testDir)}`);
console.error(`See error output above.`);

throw new IntegrationTestCommandError();
}
}
}
Expand Down

0 comments on commit 03acd84

Please sign in to comment.