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

Commit7ec46c9

Browse files
committed
test running progress
1 parent6190afe commit7ec46c9

File tree

5 files changed

+77
-65
lines changed

5 files changed

+77
-65
lines changed

‎src/editor/commands/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
7373
console.log('save document',document)
7474
if(languageIds.includes(document.languageId)&&document.uri.scheme==='file'){
7575
// do work
76-
vscode.commands.executeCommand('coderoad.run_test')
76+
machine.send('TEST_RUN')
7777
}
7878
})
7979
},
@@ -104,6 +104,9 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
104104
machine.send(action)
105105
},
106106
[COMMANDS.RUN_TEST]:()=>{
107-
runTest()
107+
runTest({
108+
onSuccess:()=>machine.send('TEST_PASS'),
109+
onFail:()=>machine.send('TEST_FAIL')
110+
})
108111
}
109112
})

‎src/editor/commands/runTest.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import*asvscodefrom'vscode'
22
import{exec}from'../../services/node'
33
import*asstoragefrom'../../services/storage'
4-
import*astestResultfrom'../../services/testResult'
54

65
// ensure only latest run_test action is taken
76
letcurrentId=0
@@ -21,7 +20,12 @@ const getOutputChannel = (name: string): vscode.OutputChannel => {
2120
return_channel
2221
}
2322

24-
exportdefaultasyncfunctionrunTest():Promise<void>{
23+
interfaceProps{
24+
onSuccess():void,
25+
onFail():void
26+
}
27+
28+
exportdefaultasyncfunctionrunTest({ onSuccess, onFail}:Props):Promise<void>{
2529
// increment process id
2630
letprocessId=++currentId
2731

@@ -73,8 +77,8 @@ export default async function runTest(): Promise<void> {
7377
// exit early
7478
return
7579
}
76-
//@ts-ignore
77-
testResult.onSuccess(position)
80+
console.log('call onSuccess')
81+
onSuccess()
7882
}else{
7983
console.log('NOT SUCCESS?')
8084
}
@@ -118,7 +122,8 @@ export default async function runTest(): Promise<void> {
118122
return
119123
}
120124
console.log('ERROR',firstError.message)
121-
testResult.onFailure()
125+
console.log('call onFail')
126+
onFail()
122127
}else{
123128
console.error('NOTE: PARSER DID NOT WORK FOR ',line)
124129
}

‎src/services/testResult.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
import*asCRfrom'typings'
2-
import*asvscodefrom'vscode'
3-
import*asstoragefrom'./storage'
4-
5-
exportasyncfunctiononSuccess(position:CR.Position){
6-
console.log('onSuccess',position)
7-
vscode.window.showInformationMessage('SUCCESS')
8-
9-
// calculate progress changes
10-
const[progress,tutorial]=awaitPromise.all([storage.getProgress(),storage.getTutorial()])
11-
12-
if(!tutorial){
13-
thrownewError('No tutorial found')
14-
}
15-
16-
if(!position.stepId){
17-
thrownewError('No step position found')
18-
}
19-
20-
const{ data}=tutorial
21-
22-
// step complete
23-
constnextProgress=progress
24-
nextProgress.steps[position.stepId]=true
25-
26-
// is stage complete
27-
conststeps=data.stages[position.stageId].stepList
28-
constisStageComplete=progress.stages[position.stageId]||steps[steps.length-1]===position.stepId
29-
nextProgress.stages[position.stageId]=isStageComplete
30-
31-
// is level complete
32-
if(isStageComplete){
33-
conststages=data.levels[position.levelId].stageList
34-
constisLevelComplete=progress.levels[position.levelId]||stages[stages.length-1]===position.stageId
35-
nextProgress.levels[position.levelId]=isLevelComplete
36-
37-
if(isLevelComplete){
38-
constlevels=data.summary.levelList
39-
constisTutorialComplete=progress.complete||levels[levels.length-1]===position.levelId
40-
nextProgress.complete=isTutorialComplete
41-
}
42-
}
43-
console.log('nextProgress',nextProgress)
44-
45-
// update ls progress
46-
storage.updateProgress(nextProgress)
47-
// send({ type: 'STEP_COMPLETE', payload: { progress: nextProgress }})
48-
}
49-
50-
exportasyncfunctiononFailure(){
51-
// TODO: capture analytics on stepId
52-
vscode.window.showWarningMessage('FAIL')
53-
}
1+
//import * as CR from 'typings'
2+
//import * as vscode from 'vscode'
3+
//import * as storage from './storage'
4+
5+
//export async function onSuccess(position: CR.Position) {
6+
// console.log('onSuccess', position)
7+
// vscode.window.showInformationMessage('SUCCESS')
8+
9+
// // calculate progress changes
10+
// const [progress, tutorial] = await Promise.all([storage.getProgress(), storage.getTutorial()])
11+
12+
// if (!tutorial) {
13+
// throw new Error('No tutorial found')
14+
// }
15+
16+
// if (!position.stepId) {
17+
// throw new Error('No step position found')
18+
// }
19+
20+
// const { data } = tutorial
21+
22+
// // step complete
23+
// const nextProgress = progress
24+
// nextProgress.steps[position.stepId] = true
25+
26+
// // is stage complete
27+
// const steps = data.stages[position.stageId].stepList
28+
// const isStageComplete = progress.stages[position.stageId] || steps[steps.length - 1] === position.stepId
29+
// nextProgress.stages[position.stageId] = isStageComplete
30+
31+
// // is level complete
32+
// if (isStageComplete) {
33+
// const stages = data.levels[position.levelId].stageList
34+
// const isLevelComplete = progress.levels[position.levelId] || stages[stages.length - 1] === position.stageId
35+
// nextProgress.levels[position.levelId] = isLevelComplete
36+
37+
// if (isLevelComplete) {
38+
// const levels = data.summary.levelList
39+
// const isTutorialComplete = progress.complete || levels[levels.length - 1] === position.levelId
40+
// nextProgress.complete = isTutorialComplete
41+
// }
42+
// }
43+
// console.log('nextProgress', nextProgress)
44+
45+
// // update ls progress
46+
// storage.updateProgress(nextProgress)
47+
// // send({ type: 'STEP_COMPLETE', payload: { progress: nextProgress }})
48+
//}
49+
50+
//export async function onFailure() {
51+
// // TODO: capture analytics on stepId
52+
// vscode.window.showWarningMessage('FAIL')
53+
//}

‎src/state/actions/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,8 @@ export default {
8484
}),
8585
tutorialLoadNext(){
8686
machine.send('LOAD_NEXT')
87+
},
88+
testStart(){
89+
vscode.commands.executeCommand('coderoad.run_test')
8790
}
8891
}

‎src/state/machine.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const machine = Machine<
2121
states:{
2222
Initial:{
2323
after:{
24-
1000:'Startup'
24+
2000:'Startup'
2525
}
2626
},
2727
Startup:{
@@ -101,8 +101,9 @@ export const machine = Machine<
101101
},
102102
},
103103
TestRunning:{
104+
onEntry:['testStart'],
104105
on:{
105-
TEST_SUCCESS:[
106+
TEST_PASS:[
106107
{
107108
target:'StageComplete',
108109
cond:'tasksComplete',
@@ -111,7 +112,7 @@ export const machine = Machine<
111112
target:'TestPass',
112113
},
113114
],
114-
TEST_FAILURE:'TestFail',
115+
TEST_FAIL:'TestFail',
115116
},
116117
},
117118
TestPass:{
@@ -129,8 +130,8 @@ export const machine = Machine<
129130
},
130131
},
131132
TestFail:{
132-
on:{
133-
RETURN:'StageNormal',
133+
after:{
134+
0:'StageNormal'
134135
},
135136
},
136137
StageComplete:{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp