Skip to content

testing: add autosave before each test run#141254

Merged
connor4312 merged 4 commits intomicrosoft:mainfrom
Kalmaegi:main
Jan 26, 2022
Merged

testing: add autosave before each test run#141254
connor4312 merged 4 commits intomicrosoft:mainfrom
Kalmaegi:main

Conversation

@Kalmaegi
Copy link
Contributor

Save the current project file before each test run so that the code logic is up to date when the test is run

This PR fixes #139125

Save the current project file before each test run so that the code logic is up to date when the test is run
@connor4312
Copy link
Member

connor4312 commented Jan 24, 2022

We should make this configurable, and do it like how debug does. For example:

export async function saveAllBeforeDebugStart(configurationService: IConfigurationService, editorService: IEditorService): Promise<void> {
const saveBeforeStartConfig: string = configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: editorService.activeTextEditorLanguageId });
if (saveBeforeStartConfig !== 'none') {
await editorService.saveAll();
if (saveBeforeStartConfig === 'allEditorsInActiveGroup') {
const activeEditor = editorService.activeEditorPane;
if (activeEditor && activeEditor.input.resource?.scheme === Schemas.untitled) {
// Make sure to save the active editor in case it is in untitled file it wont be saved as part of saveAll #111850
await editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
}
}
}
await configurationService.reloadConfiguration();
}

Also, this should probably trigger only for runs that are triggered via the UI, not API. Example of checking that:

if (result.request.isUiTriggered === false) {
return;
}

@Kalmaegi
Copy link
Contributor Author

We should make this configurable, and do it like how debug does. For example:

Okay!

@Kalmaegi
Copy link
Contributor Author

@connor4312 Do you think we need to consider untitled file? running test is more frequent than starting debug, I was worried about the impact on the time

@connor4312
Copy link
Member

I don't think we need to deal with untitled files. It's unlikely that test runners will discover tests in untitled files.

@Kalmaegi
Copy link
Contributor Author

I don't think we need to deal with untitled files. It's unlikely that test runners will discover tests in untitled files.

Yes, this is somewhat unnecessary

@connor4312
Copy link
Member

Looks good, thanks! This'll go out in the release next week

@connor4312 connor4312 merged commit 5adeb09 into microsoft:main Jan 26, 2022
@connor4312 connor4312 added this to the January 2022 milestone Jan 26, 2022
@Kalmaegi
Copy link
Contributor Author

Looks good, thanks! This'll go out in the release next week

I'm learning to work with testing these days, and I'm really glad I could help!

@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to auto save when running tests

3 participants