Skip to content
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

Add new r.packageTestExplorer command #6419

Merged
merged 8 commits into from
Feb 26, 2025
Prev Previous commit
Next Next commit
Add some workspace state to track whether tests have ever been discov…
…ered
  • Loading branch information
juliasilge committed Feb 25, 2025
commit f6c0c1b159f2e7f937e339af634068d7a347a4cc
7 changes: 7 additions & 0 deletions extensions/positron-r/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,16 @@ export async function registerCommands(context: vscode.ExtensionContext, runtime

vscode.commands.registerCommand('r.packageTestExplorer', async () => {
vscode.commands.executeCommand('workbench.view.testing.focus');

// For when we need to wait for the test explorer to load:
onDidDiscoverTestFiles(event => {
vscode.commands.executeCommand('testing.runAll');
});

// For when the test explorer is already loaded:
if (context.workspaceState.get('testExplorerSetUp') === true) {
vscode.commands.executeCommand('testing.runAll');
}
}),

vscode.commands.registerCommand('r.useTestthat', async () => {
Expand Down
2 changes: 2 additions & 0 deletions extensions/positron-r/src/testing/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const onDidDiscoverTestFiles = _onDidDiscoverTestFiles.event;


export async function setupTestExplorer(context: vscode.ExtensionContext) {
context.workspaceState.update('testExplorerSetUp', false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a global workspace state, should we somehow namespace this to positron-r? In Positron Assistant, I see a key like this: 'positron-assistant.recentFiles'.

if (testExplorerEnabled()) {
return discoverTests(context);
}
Expand Down Expand Up @@ -96,6 +97,7 @@ export async function discoverTests(context: vscode.ExtensionContext) {
context.subscriptions.push(watcher);
}
_onDidDiscoverTestFiles.fire();
context.workspaceState.update('testExplorerSetUp', true);
LOGGER.info('Testthat file watchers are in place.');
}
};
Expand Down