Skip to content

Commit

Permalink
Add new r.packageTestExplorer command
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Feb 21, 2025
1 parent 97c6800 commit 836e742
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion extensions/positron-r/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
"title": "%r.command.packageTest.title%",
"shortTitle": "%r.menu.packageTest.title%"
},
{
"command": "r.packageTestExplorer",
"category": "R",
"title": "%r.command.packageTestExplorer.title%"
},
{
"command": "r.useTestthat",
"category": "R",
Expand Down Expand Up @@ -415,7 +420,7 @@
"when": "isRPackage"
},
{
"command": "r.packageTest",
"command": "r.packageTestExplorer",
"key": "ctrl+shift+t",
"mac": "cmd+shift+t",
"when": "isRPackage"
Expand Down Expand Up @@ -520,6 +525,11 @@
"command": "r.packageTest",
"when": "isRPackage"
},
{
"category": "R",
"command": "r.packageTestExplorer",
"when": "isRPackage"
},
{
"category": "R",
"command": "r.packageCheck",
Expand Down
3 changes: 2 additions & 1 deletion extensions/positron-r/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"r.command.insertSection.title": "Insert a new section",
"r.command.packageBuild.title": "Build R Package",
"r.command.packageInstall.title": "Install R Package and Restart R",
"r.command.packageTest.title": "Test R Package",
"r.command.packageTest.title": "Test R Package in Terminal",
"r.command.packageTestExplorer.title": "Test R Package in Test Explorer",
"r.command.useTestthat.title": "Configure testthat",
"r.command.useTest.title": "Add (or visit) a test file",
"r.command.packageCheck.title": "Check R Package",
Expand Down
9 changes: 8 additions & 1 deletion extensions/positron-r/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';
import * as positron from 'positron';
import { PromiseHandles, timeout } from './util';
import { PromiseHandles, delay } from './util';
import { checkInstalled } from './session';
import { getRPackageName } from './contexts';
import { getRPackageTasks } from './tasks';
Expand Down Expand Up @@ -126,6 +126,13 @@ export async function registerCommands(context: vscode.ExtensionContext, runtime
}
}),

vscode.commands.registerCommand('r.packageTestExplorer', async () => {
vscode.commands.executeCommand('workbench.view.testing.focus');
// Wait for the test explorer to set up before running tests
await delay(500);
vscode.commands.executeCommand('testing.runAll');
}),

vscode.commands.registerCommand('r.useTestthat', async () => {
executeCodeForCommand('usethis', 'usethis::use_testthat()');
}),
Expand Down

0 comments on commit 836e742

Please sign in to comment.