-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(integ-runner): support custom
--test-regex
to match integ test…
… files (#22786) Follow-up to #22761. To support other languages than JavaScript (see #22521) we need to be able to detect test files with any patterns. With this PR, users can specify a number of custom `--test-regex` patterns that will bed used to discover integration test files. Together with `--app` this can already be used to run integ tests in arbitrary languages. Example usage: `integ-runner --app="python3 {filePath}" --test-regex="^integ_.*\.py$"` Also contains a minor refactor to make `--app` available via `IntegrationTests.fromFile()`. This is in preparation of an upcoming change to reestablish support for an integration test config file. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
10 changed files
with
276 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as path from 'path'; | ||
import { main } from '../lib/cli'; | ||
|
||
describe('CLI', () => { | ||
const currentCwd = process.cwd(); | ||
beforeAll(() => { | ||
process.chdir(path.join(__dirname, '..')); | ||
}); | ||
afterAll(() => { | ||
process.chdir(currentCwd); | ||
}); | ||
|
||
let stdoutMock: jest.SpyInstance; | ||
beforeEach(() => { | ||
stdoutMock = jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); | ||
}); | ||
afterEach(() => { | ||
stdoutMock.mockRestore(); | ||
}); | ||
|
||
test('find by default pattern', async () => { | ||
await main(['--list', '--directory=test/test-data']); | ||
|
||
// Expect nothing to be found since this directory doesn't contain files with the default pattern | ||
expect(stdoutMock.mock.calls).toEqual([['\n']]); | ||
}); | ||
|
||
test('find by custom pattern', async () => { | ||
await main(['--list', '--directory=test/test-data', '--test-regex="^xxxxx\..*\.js$"']); | ||
|
||
expect(stdoutMock.mock.calls).toEqual([[ | ||
[ | ||
'xxxxx.integ-test1.js', | ||
'xxxxx.integ-test2.js', | ||
'xxxxx.test-with-new-assets-diff.js', | ||
'xxxxx.test-with-new-assets.js', | ||
'xxxxx.test-with-snapshot-assets-diff.js', | ||
'xxxxx.test-with-snapshot-assets.js', | ||
'xxxxx.test-with-snapshot.js', | ||
'', | ||
].join('\n'), | ||
]]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.