-
Notifications
You must be signed in to change notification settings - Fork 5k
feat(test runner): --only-changed option
#31727
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
Changes from all commits
da65da5
30447b1
9123e1d
2d9a299
d907883
824bea2
72d7c86
bed4466
0cbfd34
5cb24de
5b75823
ce788a6
5d2da71
9fb7f13
822c4cb
f672d6d
0f38048
359edf9
ab05bbf
2251e6a
7bb2780
6baf0b6
a5d7ca1
8de6851
91ba44c
6c19e0e
5bdeb38
fbcfdb5
397b66d
a11e7fb
76e63c4
b618a61
9398347
2e6ed2f
226e00b
f530806
8493789
1665d8f
b9fe830
eb19971
38a16c5
0b2a74e
193977b
b1c04b1
ed43475
ffc3f7f
6ec936f
9a32dad
dda6532
338790f
065f5ce
805561a
22977e0
92c9253
55bace0
6e2f581
7716b23
961cafc
acdde57
bc96c8b
4355c7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Copyright Microsoft Corporation. All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import childProcess from 'child_process'; | ||
| import { affectedTestFiles } from '../transform/compilationCache'; | ||
| import path from 'path'; | ||
|
|
||
| export async function detectChangedTests(baseCommit: string, configDir: string): Promise<Set<string>> { | ||
| function gitFileList(command: string) { | ||
| try { | ||
| return childProcess.execSync( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want to pass
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. smart! done in 7716b23. I'll still keep the path mapping in line 42, because we the |
||
| `git ${command}`, | ||
| { encoding: 'utf-8', stdio: 'pipe', cwd: configDir } | ||
| ).split('\n').filter(Boolean); | ||
| } catch (_error) { | ||
| const error = _error as childProcess.SpawnSyncReturns<string>; | ||
| throw new Error([ | ||
| `Cannot detect changed files for --only-changed mode:`, | ||
| `git ${command}`, | ||
| '', | ||
| ...error.output, | ||
| ].join('\n')); | ||
| } | ||
| } | ||
|
|
||
| const untrackedFiles = gitFileList(`ls-files --others --exclude-standard`).map(file => path.join(configDir, file)); | ||
|
|
||
| const [gitRoot] = gitFileList('rev-parse --show-toplevel'); | ||
| const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`).map(file => path.join(gitRoot, file)); | ||
|
|
||
| return new Set(affectedTestFiles([...untrackedFiles, ...trackedFilesWithChanges])); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.