Skip to content

Commit aa9ac76

Browse files
committed
Add shortcut to run all test suites
1 parent 00dc2f3 commit aa9ac76

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Dans les petits plus, mettre en couleur les composants pourrait être intéressa
1717

1818
## Medium priority
1919

20+
* Handle multiple test suites
2021
* High-Z bus logic
2122
* Allow to swap RAM width/height (for Christophe Declercq)
2223
* Add tootips to components, e.g., describe what happens on the next state transition, etc.

simulator/src/TestsPalette.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ export class TestsPalette {
9999
}
100100
}
101101

102+
public async runAllTestSuites() {
103+
for (const testSuiteUI of this.testSuites.values()) {
104+
await testSuiteUI.runTestCases()
105+
}
106+
}
107+
102108
}
103109

104110

@@ -108,6 +114,7 @@ export class TestSuiteUI {
108114

109115
public readonly rootElem: HTMLDivElement
110116
private readonly header: HTMLDivElement
117+
private readonly runTestCasesButton: HTMLSpanElement
111118
private readonly content: HTMLDivElement
112119
private _expanded = false
113120

@@ -124,27 +131,16 @@ export class TestSuiteUI {
124131

125132
const runAllIcon = makeIcon("play")
126133
style("position: relative; top: -2px;").applyTo(runAllIcon)
127-
const runAllButton = span(cls("sim-mode-link"), style("flex: none; font-size: 85%; opacity: 0.9; margin: -2px 0 -2px 4px; padding: 2px 4px 0 0;"),
134+
this.runTestCasesButton = span(cls("sim-mode-link"), style("flex: none; font-size: 85%; opacity: 0.9; margin: -2px 0 -2px 4px; padding: 2px 4px 0 0;"),
128135
title(s.RunTestSuite), runAllIcon, s.Run
129136
).render()
130137

131-
runAllButton.addEventListener("click", async () => {
132-
const oldExpanded = this.expanded
133-
setHidden(runAllButton, true)
134-
try {
135-
const testResult = await this.editor.runTestSuite(this.testSuite, { fast: true })
136-
if (testResult !== undefined && testResult.isAllPass()) {
137-
this.expanded = oldExpanded
138-
}
139-
} finally {
140-
setHidden(runAllButton, false)
141-
}
142-
})
138+
this.runTestCasesButton.addEventListener("click", () => this.runTestCases())
143139

144140
this.header =
145141
div(cls("test-suite test-disclosable expanded"), style("display: flex"),
146142
span(style("flex: auto"), testSuite.name ?? s.DefaultTestSuiteName),
147-
runAllButton
143+
this.runTestCasesButton
148144
).render()
149145
this.content =
150146
div(cls("test-cases"), style("display: block"), ...this.htmlResults.map(p => p.container)).render()
@@ -223,6 +219,19 @@ export class TestSuiteUI {
223219
this.palette.updateMaxHeight()
224220
}
225221

222+
public async runTestCases() {
223+
const oldExpanded = this.expanded
224+
setHidden(this.runTestCasesButton, true)
225+
try {
226+
const testResult = await this.editor.runTestSuite(this.testSuite, { fast: true })
227+
if (testResult !== undefined && testResult.isAllPass()) {
228+
this.expanded = oldExpanded
229+
}
230+
} finally {
231+
setHidden(this.runTestCasesButton, false)
232+
}
233+
}
234+
226235
public setRunning(i: number) {
227236
if (!this._expanded) {
228237
this.expanded = true

simulator/src/UIEventManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,14 @@ export class UIEventManager {
497497
editor.setCurrentMouseAction("move")
498498
e.preventDefault()
499499
return
500+
501+
case "t":
502+
if (editor.editorRoot.testSuites.totalCases() > 0) {
503+
editor.setTestsPaletteVisible(true)
504+
editor.editTools.testsPalette.runAllTestSuites()
505+
e.preventDefault()
506+
return
507+
}
500508
}
501509
}))
502510

0 commit comments

Comments
 (0)