Skip to content

Commit

Permalink
fix(integ-runner): test names change depending on the discovery direc…
Browse files Browse the repository at this point in the history
…tory

The name of the test that is stored in the `integ.json` file for legacy
test cases changes depending on what directory you run the test from.

For example, if you were to run the below command from the root of the
project the test name would be
`@aws-cdk/aws-lambda/test/integ.assets.file`

`yarn integ-runner --directory package/@aws-cdk/aws-lambda
test/integ.assets.file.js`

If you were to run this command from the `packages/@aws-cdk/aws-lambda`
directory then the test name would be `integ.assets.file`

`yarn integ integ.assets.file.js`

This PR attempts to normalize the test name by using the name of the
integration test file, minus the file extension.

**Note, this only affects legacy test cases. The new style test cases
have a different mechanism to generate a test name.

I will create a follow up PR to update all of the `integ.json` files for
all of the existing test cases to have the normalized name.
  • Loading branch information
corymhall committed Jul 11, 2022
1 parent 42d1d7c commit f37b07d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class IntegTest {
*/
public readonly absoluteFileName: string;

/**
* The normalized name of the test. This name
* will be the same regardless of what directory the tool
* is run from.
*/
public readonly normalizedTestName: string;

/**
* Directory the test is in
*/
Expand Down Expand Up @@ -91,6 +98,7 @@ export class IntegTest {
: path.join(path.relative(this.info.discoveryRoot, parsed.dir), parsed.name);

const nakedTestName = parsed.name.slice(6); // Leave name without 'integ.' and '.ts'
this.normalizedTestName = parsed.name;
this.snapshotDir = path.join(this.directory, `${nakedTestName}.integ.snapshot`);
this.temporaryOutputDir = path.join(this.directory, `${CDK_OUTDIR_PREFIX}.${nakedTestName}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export abstract class IntegRunner {
} catch (e) {
const testCases = LegacyIntegTestSuite.fromLegacy({
cdk: this.cdk,
testName: this.testName,
testName: this.test.normalizedTestName,
integSourceFilePath: this.test.fileName,
listOptions: {
...this.defaultArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('IntegTest runSnapshotTests', () => {

// THEN
expect(integTest.actualTests()).toEqual(expect.objectContaining({
'test-data/xxxxx.integ-test1': {
'xxxxx.integ-test1': {
diffAssets: false,
stackUpdateWorkflow: true,
stacks: ['stack1'],
Expand All @@ -197,7 +197,7 @@ describe('IntegTest runSnapshotTests', () => {

// THEN
expect(integTest.actualTests()).toEqual(expect.objectContaining({
'test-data/xxxxx.integ-test2': {
'xxxxx.integ-test2': {
diffAssets: false,
stackUpdateWorkflow: true,
stacks: ['stackabc'],
Expand Down

0 comments on commit f37b07d

Please sign in to comment.