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

Commita690ce0

Browse files
committed
pass filter arg to test
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent37b5b53 commita690ce0

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

‎src/actions/tutorialConfig.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import * as git from '../services/git'
66
import{DISABLE_RUN_ON_SAVE}from'../environment'
77

88
interfaceTutorialConfigParams{
9-
config:TT.TutorialConfig
9+
data:TT.Tutorial
1010
alreadyConfigured?:boolean
1111
onComplete?():void
1212
}
1313

14-
consttutorialConfig=async({config, alreadyConfigured}:TutorialConfigParams):Promise<E.ErrorMessage|void>=>{
14+
consttutorialConfig=async({data, alreadyConfigured}:TutorialConfigParams):Promise<E.ErrorMessage|void>=>{
1515
if(!alreadyConfigured){
1616
// setup git, add remote
1717
constinitError:E.ErrorMessage|void=awaitgit.initIfNotExists().catch(
@@ -27,7 +27,7 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
2727
}
2828

2929
// verify that internet is connected, remote exists and branch exists
30-
constremoteConnectError:E.ErrorMessage|void=awaitgit.checkRemoteConnects(config.repo).catch(
30+
constremoteConnectError:E.ErrorMessage|void=awaitgit.checkRemoteConnects(data.config.repo).catch(
3131
(error:Error):E.ErrorMessage=>({
3232
type:'FailedToConnectToGitRepo',
3333
message:error.message,
@@ -40,7 +40,7 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
4040
}
4141

4242
// TODO if remote not already set
43-
constcoderoadRemoteError:E.ErrorMessage|void=awaitgit.setupCodeRoadRemote(config.repo.uri).catch(
43+
constcoderoadRemoteError:E.ErrorMessage|void=awaitgit.setupCodeRoadRemote(data.config.repo.uri).catch(
4444
(error:Error):E.ErrorMessage=>({
4545
type:'GitRemoteAlreadyExists',
4646
message:error.message,
@@ -52,7 +52,7 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
5252
}
5353
}
5454

55-
awaitvscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER,config.testRunner)
55+
awaitvscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER,data)
5656

5757
if(!DISABLE_RUN_ON_SAVE){
5858
// verify if file test should run based on document saved

‎src/channel/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Channel implements Channel {
204204
}
205205
}
206206

207-
consterror:E.ErrorMessage|void=awaittutorialConfig({config:data.config}).catch((error:Error)=>({
207+
consterror:E.ErrorMessage|void=awaittutorialConfig({ data}).catch((error:Error)=>({
208208
type:'UnknownError',
209209
message:`Location: tutorial config.\n\n${error.message}`,
210210
}))
@@ -231,9 +231,8 @@ class Channel implements Channel {
231231
if(!tutorialContinue){
232232
thrownewError('Invalid tutorial to continue')
233233
}
234-
constcontinueConfig:TT.TutorialConfig=tutorialContinue.config
235234
awaittutorialConfig({
236-
config:continueConfig,
235+
data:tutorialContinue,
237236
alreadyConfigured:true,
238237
})
239238
// update the current stepId on startup

‎src/editor/commands.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
5050
// setup 1x1 horizontal layout
5151
webview.createOrShow()
5252
},
53-
[COMMANDS.CONFIG_TEST_RUNNER]:async(config:TT.TestRunnerConfig)=>{
54-
constsetup=config.setup||config.actions// TODO: deprecate and remove config.actions
53+
[COMMANDS.CONFIG_TEST_RUNNER]:async(data:TT.Tutorial)=>{
54+
consttestRunnerConfig=data.config.testRunner
55+
constsetup=testRunnerConfig.setup||testRunnerConfig.actions// TODO: deprecate and remove config.actions
5556
if(setup){
5657
// setup tutorial test runner commits
5758
// assumes git already exists
58-
awaitsetupActions({actions:setup,send:webview.send,dir:config.directory||config.path})// TODO: deprecate and remove config.path
59+
awaitsetupActions({
60+
actions:setup,
61+
send:webview.send,
62+
dir:testRunnerConfig.directory||testRunnerConfig.path,
63+
})// TODO: deprecate and remove config.path
5964
}
60-
testRunner=createTestRunner(config,{
65+
testRunner=createTestRunner(data,{
6166
onSuccess:(position:T.Position)=>{
6267
logger('test pass position',position)
6368
// send test pass message back to client
@@ -89,7 +94,8 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
8994
// ...current,
9095
// stepId: current && current.position.stepId?.length ? current.position.stepId : currentPosition.stepId,
9196
// }
92-
testRunner(currentPosition,callback?.onSuccess)
97+
logger('currentPosition',currentPosition)
98+
testRunner({position:currentPosition,onSuccess:callback?.onSuccess})
9399
},
94100
}
95101
}

‎src/services/testRunner/index.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ const logChannelName = 'CodeRoad (Logs)'
2020

2121
interfaceTestRunnerParams{
2222
position:T.Position
23-
filter?:string
2423
onSuccess?:()=>void
2524
}
2625

27-
constcreateTestRunner=(config:TT.TestRunnerConfig,callbacks:Callbacks)=>{
28-
consttestRunnerFilterArg=config.args?.filter
29-
returnasync({ position,filter:testFilter, onSuccess}:TestRunnerParams):Promise<void>=>{
30-
logger('createTestRunner',position)
26+
constcreateTestRunner=(data:TT.Tutorial,callbacks:Callbacks)=>{
27+
consttestRunnerConfig=data.config.testRunner
28+
consttestRunnerFilterArg=testRunnerConfig.args?.filter
29+
returnasync({ position, onSuccess}:TestRunnerParams):Promise<void>=>{
3130
conststartTime=throttle()
3231
// throttle time early
3332
if(!startTime){
@@ -41,17 +40,29 @@ const createTestRunner = (config: TT.TestRunnerConfig, callbacks: Callbacks) =>
4140

4241
letresult:{stdout:string|undefined;stderr:string|undefined}
4342
try{
44-
letcommand=config.args ?`${config.command}${config?.args.tap}` :config.command// TODO: enforce TAP
43+
letcommand=testRunnerConfig.args
44+
?`${testRunnerConfig.command}${testRunnerConfig?.args.tap}`
45+
:testRunnerConfig.command// TODO: enforce TAP
4546

4647
// filter tests if requested
4748
if(testRunnerFilterArg){
49+
// get tutorial step from position
50+
// check the step actions for specific command
51+
// NOTE: cannot just pass in step actions as the test can be called by:
52+
// - onEditorSave, onWatcher, onSolution, onRunTest, onSubTask
53+
constlevels=data.levels
54+
constlevel=levels.find((l)=>l.id===position.levelId)
55+
conststep=level?.steps.find((s)=>s.id===position.stepId)
56+
consttestFilter=step?.setup?.filter
4857
if(testFilter){
49-
command+=`${testRunnerFilterArg}${testFilter}`
58+
// append filter commands
59+
command=[command,testRunnerFilterArg,testFilter].join(' ')
5060
}else{
5161
thrownewError('Test Runner filter not configured')
5262
}
5363
}
54-
result=awaitexec({ command,dir:config.directory||config.path})// TODO: remove config.path later
64+
logger('COMMAND',command)
65+
result=awaitexec({ command,dir:testRunnerConfig.directory||testRunnerConfig.path})// TODO: remove config.path later
5566
}catch(err){
5667
result={stdout:err.stdout,stderr:err.stack}
5768
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp