Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d55c5a

Browse files
committed
outline test runner config changes
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent07aa070 commit5d55c5a

File tree

7 files changed

+52
-17
lines changed

7 files changed

+52
-17
lines changed

‎CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,28 @@ CODEROAD_TUTORIAL_URL='path/to/tutorial_config_file.json' // will load directly
125125
## [0.6.1]
126126

127127
- Replace checkboxes with icons
128+
129+
## [0.7.0]
130+
131+
- Change for the test runner config. Changes are backwards compatible.
132+
133+
1. `testRunner.path`=> `testRunner.directory`
134+
2. `testRunner.actions` => `testRunner.setup`
135+
3. Change command to capture `args` for "TAP" support, and test "filter"ing support. These changes will help lead to specific test suite presets in the future.
136+
137+
```json
138+
{
139+
"testRunner": {
140+
"command":"mocha",
141+
"args": {
142+
"filter":"--grep",
143+
"tap":"--reporter=mocha-tap-reporter"
144+
},
145+
"directory":".coderoad",
146+
"setup": {
147+
"commits": ["410bd4f"],
148+
"commands": ["npm install"]
149+
}
150+
}
151+
}
152+
```

‎src/actions/setupActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import logger from '../services/logger'
1010
interfaceSetupActions{
1111
actions:TT.StepActions
1212
send:(action:T.Action)=>void// send messages to client
13-
path?:string
13+
dir?:string
1414
}
1515

16-
exportconstsetupActions=async({ actions, send,path}:SetupActions):Promise<void>=>{
16+
exportconstsetupActions=async({ actions, send,dir}:SetupActions):Promise<void>=>{
1717
if(!actions){
1818
return
1919
}
@@ -45,7 +45,7 @@ export const setupActions = async ({ actions, send, path }: SetupActions): Promi
4545

4646
// 4. run command
4747
if(!alreadyLoaded){
48-
awaitrunCommands({commands:commands||[], send,path}).catch(onError)
48+
awaitrunCommands({commands:commands||[], send,dir}).catch(onError)
4949
}
5050
}
5151

‎src/actions/utils/runCommands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { exec } from '../../services/node'
44
interfaceRunCommands{
55
commands:string[]
66
send:(action:T.Action)=>void
7-
path?:string
7+
dir?:string
88
}
99

10-
construnCommands=async({ commands, send,path}:RunCommands)=>{
10+
construnCommands=async({ commands, send,dir}:RunCommands)=>{
1111
if(!commands.length){
1212
return
1313
}
@@ -19,7 +19,7 @@ const runCommands = async ({ commands, send, path }: RunCommands) => {
1919
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
2020
letresult:{stdout:string;stderr:string}
2121
try{
22-
result=awaitexec({ command,path})
22+
result=awaitexec({ command,dir})
2323
console.log(result)
2424
}catch(error){
2525
console.log(`Test failed:${error.message}`)

‎src/editor/commands.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
5050
// setup 1x1 horizontal layout
5151
webview.createOrShow()
5252
},
53-
[COMMANDS.CONFIG_TEST_RUNNER]:async(config:TT.TutorialTestRunnerConfig)=>{
54-
if(config.actions){
53+
[COMMANDS.CONFIG_TEST_RUNNER]:async(config:TT.TestRunnerConfig)=>{
54+
constsetup=config.setup||config.actions// TODO: depreacte and remove config.actions
55+
if(setup){
5556
// setup tutorial test runner commits
5657
// assumes git already exists
57-
awaitsetupActions({actions:config.actions,send:webview.send,path:config.path})
58+
awaitsetupActions({actions:setup,send:webview.send,dir:config.directory||config.path})// TODO: deprecate and remove config.path
5859
}
5960
testRunner=createTestRunner(config,{
6061
onSuccess:(position:T.Position)=>{

‎src/services/node/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const asyncExec = promisify(cpExec)
88

99
interfaceExecParams{
1010
command:string
11-
path?:string
11+
dir?:string
1212
}
1313

1414
exportconstexec=(params:ExecParams):Promise<{stdout:string;stderr:string}>|never=>{
15-
constcwd=join(WORKSPACE_ROOT,params.path||'')
15+
constcwd=join(WORKSPACE_ROOT,params.dir||'')
1616
returnasyncExec(params.command,{ cwd})
1717
}
1818

‎src/services/testRunner/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Callbacks {
1818
constfailChannelName='CodeRoad (Tests)'
1919
constlogChannelName='CodeRoad (Logs)'
2020

21-
constcreateTestRunner=(config:TT.TutorialTestRunnerConfig,callbacks:Callbacks)=>{
21+
constcreateTestRunner=(config:TT.TestRunnerConfig,callbacks:Callbacks)=>{
2222
returnasync(position:T.Position,onSuccess?:()=>void):Promise<void>=>{
2323
logger('createTestRunner',position)
2424
conststartTime=throttle()
@@ -34,7 +34,8 @@ const createTestRunner = (config: TT.TutorialTestRunnerConfig, callbacks: Callba
3434

3535
letresult:{stdout:string|undefined;stderr:string|undefined}
3636
try{
37-
result=awaitexec({command:config.command,path:config.path})
37+
constcommand=config.args ?`${config.command}${config?.args.tap}` :config.command// TODO: enforce TAP
38+
result=awaitexec({ command,dir:config.directory||config.path})// TODO: remove config.path later
3839
}catch(err){
3940
result={stdout:err.stdout,stderr:err.stack}
4041
}

‎typings/tutorial.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type Maybe<T> = T | null
22

33
exporttypeTutorialConfig={
44
appVersions:TutorialAppVersions
5-
testRunner:TutorialTestRunnerConfig
5+
testRunner:TestRunnerConfig
66
repo:TutorialRepo
77
dependencies?:TutorialDependency[]
88
}
@@ -52,10 +52,18 @@ export type StepActions = {
5252
subtasks?:string[]
5353
}
5454

55-
exportinterfaceTutorialTestRunnerConfig{
55+
exportinterfaceTestRunnerArgs{
56+
filter?:string
57+
tap:string
58+
}
59+
60+
exportinterfaceTestRunnerConfig{
5661
command:string
57-
path?:string
58-
actions?:StepActions
62+
args?:TestRunnerArgs
63+
path?:string// deprecated
64+
directory?:string
65+
actions?:StepActions// deprecated
66+
setup?:StepActions
5967
}
6068

6169
exportinterfaceTutorialRepo{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp