Skip to content

Commit

Permalink
other resulting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealAmazonKendra committed Oct 7, 2024
1 parent 4d941aa commit 4acc721
Show file tree
Hide file tree
Showing 18 changed files with 45,155 additions and 286 deletions.
74 changes: 41 additions & 33 deletions packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable no-console */
import * as fs from 'fs';
import * as path from 'path';
import { MemoryStream } from './corking';

const SKIP_TESTS = fs.readFileSync(path.join(__dirname, '..', 'skip-tests.txt'), { encoding: 'utf-8' })
const SKIP_TESTS = fs
.readFileSync(path.join(__dirname, '..', 'skip-tests.txt'), { encoding: 'utf-8' })
.split('\n')
.map(x => x.trim())
.filter(x => x && !x.startsWith('#'));
.map((x) => x.trim())
.filter((x) => x && !x.startsWith('#'));

if (SKIP_TESTS) {
process.stderr.write(`ℹ️ Skipping tests: ${JSON.stringify(SKIP_TESTS)}\n`);
Expand Down Expand Up @@ -38,37 +40,41 @@ export function integTest(
const testKind = process.env.JEST_TEST_CONCURRENT === 'true' ? test.concurrent : test;
const runner = shouldSkip(name) ? testKind.skip : testKind;

runner(name, async () => {
const output = new MemoryStream();
runner(
name,
async () => {
const output = new MemoryStream();

output.write('================================================================\n');
output.write(`${name}\n`);
output.write('================================================================\n');
output.write('================================================================\n');
output.write(`${name}\n`);
output.write('================================================================\n');

const now = Date.now();
process.stderr.write(`[INTEG TEST::${name}] Starting (pid ${process.pid})...\n`);
try {
return await callback({
output,
randomString: randomString(),
log(s: string) {
output.write(`${s}\n`);
},
});
} catch (e: any) {
process.stderr.write(`[INTEG TEST::${name}] Failed: ${e}\n`);
output.write(e.message);
output.write(e.stack);
// Print output only if the test fails. Use 'console.log' so the output is buffered by
// jest and prints without a stack trace (if verbose: false).
// eslint-disable-next-line no-console
console.log(output.buffer().toString());
throw e;
} finally {
const duration = Date.now() - now;
process.stderr.write(`[INTEG TEST::${name}] Done (${duration} ms).\n`);
}
}, timeoutMillis);
const now = Date.now();
process.stderr.write(`[INTEG TEST::${name}] Starting (pid ${process.pid})...\n`);
try {
return await callback({
output,
randomString: randomString(),
log(s: string) {
output.write(`${s}\n`);
},
});
} catch (e: any) {
process.stderr.write(`[INTEG TEST::${name}] Failed: ${e}\n`);
output.write(e.message);
output.write(e.stack);
// Print output only if the test fails. Use 'console.log' so the output is buffered by
// jest and prints without a stack trace (if verbose: false).
// eslint-disable-next-line no-console
console.log(output.buffer().toString());
throw e;
} finally {
const duration = Date.now() - now;
process.stderr.write(`[INTEG TEST::${name}] Done (${duration} ms).\n`);
}
},
timeoutMillis,
);
}

function shouldSkip(testName: string) {
Expand All @@ -77,5 +83,7 @@ function shouldSkip(testName: string) {

export function randomString() {
// Crazy
return Math.random().toString(36).replace(/[^a-z0-9]+/g, '');
return Math.random()
.toString(36)
.replace(/[^a-z0-9]+/g, '');
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4acc721

Please sign in to comment.