@@ -3,6 +3,7 @@ import * as TT from 'typings/tutorial'
33import { exec } from '../node'
44import logger from '../logger'
55import parser , { ParserOutput } from './parser'
6+ import parseSubtasks from './subtasks'
67import { debounce , throttle } from './throttle'
78import onError from '../sentry/onError'
89import { clearOutput , addOutput } from './output'
@@ -13,7 +14,7 @@ interface Callbacks {
1314onFail ( position :T . Position , failSummary :T . TestFail ) :void
1415onRun ( position :T . Position ) :void
1516onError ( position :T . Position ) :void
16- onLoadSubtasks ( { summary} :{ summary :{ [ testName : string ] :boolean } } ) :void
17+ onLoadSubtasks ( { summary} :{ summary :{ [ testId : number ] :boolean } } ) :void
1718}
1819
1920const failChannelName = 'CodeRoad (Tests)'
@@ -28,7 +29,7 @@ interface TestRunnerParams {
2829const createTestRunner = ( data :TT . Tutorial , callbacks :Callbacks ) => {
2930const testRunnerConfig = data . config . testRunner
3031const testRunnerFilterArg = testRunnerConfig . args ?. filter
31- return async ( { position, onSuccess, subtasks } :TestRunnerParams ) :Promise < void > => {
32+ return async ( { position, onSuccess} :TestRunnerParams ) :Promise < void > => {
3233const startTime = throttle ( )
3334// throttle time early
3435if ( ! startTime ) {
@@ -37,8 +38,24 @@ const createTestRunner = (data: TT.Tutorial, callbacks: Callbacks) => {
3738
3839logger ( '------------------- RUN TEST -------------------' )
3940
41+ // calculate level & step from position
42+ const level :TT . Level | null = data . levels . find ( ( l ) => l . id === position . levelId ) || null
43+ if ( ! level ) {
44+ console . warn ( `Level "${ position . levelId } " not found` )
45+ return
46+ }
47+ const step :TT . Step | null = level . steps . find ( ( s ) => s . id === position . stepId ) || null
48+ if ( ! step ) {
49+ console . warn ( `Step "${ position . stepId } " not found` )
50+ return
51+ }
52+
53+ console . log ( 'STEP' )
54+ console . log ( JSON . stringify ( step ) )
55+
4056// flag as running
41- if ( ! subtasks ) {
57+ // no need to flag subtasks as running
58+ if ( ! step . setup ?. subtasks ) {
4259callbacks . onRun ( position )
4360}
4461
@@ -81,8 +98,12 @@ const createTestRunner = (data: TT.Tutorial, callbacks: Callbacks) => {
8198
8299const tap :ParserOutput = parser ( stdout || '' )
83100
84- if ( subtasks ) {
85- callbacks . onLoadSubtasks ( { summary :tap . summary } )
101+ if ( step . setup . subtasks ) {
102+ const summary = parseSubtasks ( tap . summary , position . stepId || '' )
103+
104+ console . log ( '---subtask summary' )
105+ console . log ( summary )
106+ callbacks . onLoadSubtasks ( { summary} )
86107// exit early
87108return
88109}