Skip to content

Commit 514b2ad

Browse files
committed
prepare for test runner tests
Signed-off-by: shmck <[email protected]>
1 parent 6f1c7ff commit 514b2ad

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

src/validate.ts

+17-20
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ async function validate(args: string[]) {
7878
}
7979

8080
for (const level of skeleton.levels) {
81-
if (level.setup) {
81+
if (level?.setup) {
8282
// load commits
8383
if (commits[`${level.id}`]) {
8484
console.log(`Loading ${level.id} commits...`);
8585
await cherryPick(commits[level.id]);
8686
}
8787
// run commands
88-
if (level.setup.commands) {
88+
if (level.setup?.commands) {
8989
console.log(`Running ${level.id} commands...`);
9090
await runCommands(level.setup.commands);
9191
}
@@ -105,14 +105,17 @@ async function validate(args: string[]) {
105105
await runCommands(step.setup.commands);
106106
}
107107

108-
// ignore runnning tests on steps with no solution
109-
if (step.solution) {
108+
const stepSolutionCommits = commits[`${step.id}A`];
109+
const hasSolution = step.solution || stepSolutionCommits;
110+
111+
// ignore running tests on steps with no solution
112+
if (hasSolution) {
110113
// run test
111-
console.info("Running test");
114+
console.info("Running setup test");
115+
// expect fail
112116
// await runTest();
113117
}
114118

115-
const stepSolutionCommits = commits[`${step.id}A`];
116119
if (stepSolutionCommits) {
117120
console.info(`Loading ${step.id} solution commits...`);
118121
await cherryPick(stepSolutionCommits);
@@ -123,30 +126,24 @@ async function validate(args: string[]) {
123126
console.info(`Running ${step.id} solution commands...`);
124127
await runCommands(step.solution.commands);
125128
}
129+
130+
if (hasSolution) {
131+
// run test
132+
console.info("Running solution test");
133+
// expect pass
134+
// await runTest();
135+
}
126136
}
127137
}
128138
}
129139

130-
// run test runner setup command(s)
131-
// loop over commits:
132-
// - load level commit
133-
// - run level setup command(s)
134-
// - load step setup commit(s)
135-
// - run step setup command(s)
136-
// - if next solution:
137-
// - run test - expect fail
138-
// - if solution
139-
// - run test - expect pass
140-
141140
// log level/step
142141
// on error, show level/step & error message
143-
144-
// load INIT commit(s)
145142
} catch (e) {
146143
console.error(e.message);
147144
} finally {
148145
// cleanup
149-
// await fs.emptyDir(tmpDir);
146+
await fs.emptyDir(tmpDir);
150147
}
151148
}
152149

0 commit comments

Comments
 (0)