Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run speech system tests from monorepo #1472

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions test/system-test/test.clientlibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const gaxDir = path.resolve(__dirname, '..', '..', '..');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../package.json');
const gaxTarball = path.join(gaxDir, `${pkg.name}-${pkg.version}.tgz`);
const toolsPkg = require('../../../tools/package.json');
const toolsBasename = `${toolsPkg.name}-${toolsPkg.version}.tgz`;
const toolsTarball = path.join(gaxDir, toolsBasename);

async function latestRelease(
cwd: string,
Expand Down Expand Up @@ -121,8 +124,7 @@ async function preparePackage(
const packageJsonStr = (await readFile(packageJson)).toString();
const packageJsonObj = JSON.parse(packageJsonStr);
packageJsonObj['dependencies']['google-gax'] = `file:${gaxTarball}`;
await writeFile(packageJson, JSON.stringify(packageJsonObj, null, ' '));
packageJsonObj['dependencies']['google-gax'] = `file:${gaxTarball}`;
packageJsonObj['devDependencies']['gapic-tools'] = `file:${toolsTarball}`;
await writeFile(packageJson, JSON.stringify(packageJsonObj, null, ' '));
await execa('npm', ['install'], {
cwd: inMonorepo ? packagePath : packageName,
Expand Down Expand Up @@ -176,10 +178,25 @@ describe('Run system tests for some libraries', () => {
before(async () => {
console.log('Packing google-gax...');
await execa('npm', ['pack'], {cwd: gaxDir, stdio: 'inherit'});

if (!fs.existsSync(gaxTarball)) {
throw new Error(`npm pack tarball ${gaxTarball} does not exist`);
}
console.log('Packing gapic-tools...');
await execa('npm', ['install'], {
cwd: path.join(gaxDir, 'tools'),
stdio: 'inherit',
});
await execa('npm', ['pack'], {
cwd: path.join(gaxDir, 'tools'),
stdio: 'inherit',
});
await fs.promises.rename(
path.join(gaxDir, 'tools', toolsBasename),
toolsTarball
);
if (!fs.existsSync(toolsTarball)) {
throw new Error(`npm pack tarball ${toolsTarball} does not exist`);
}

await rmrf(testDir);
await mkdir(testDir);
Expand All @@ -188,13 +205,13 @@ describe('Run system tests for some libraries', () => {
});

// Speech has unary, LRO, and streaming
// Speech is not in the monorepo
// Speech is in the google-cloud-node monorepo
describe('speech', () => {
before(async () => {
await preparePackage('nodejs-speech', false);
await preparePackage('speech', true);
});
it('should pass system tests', async function () {
const result = await runSystemTest('nodejs-speech', false);
const result = await runSystemTest('speech', true);
if (result === TestResult.SKIP) {
this.skip();
} else if (result === TestResult.FAIL) {
Expand Down
Loading