Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion crates/yavashark_test262/runner/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ module yavashark_test262_runner

go 1.23.2

require github.com/BurntSushi/toml v1.5.0 // indirect
require (
github.com/BurntSushi/toml v1.5.0
github.com/schollz/progressbar/v3 v3.14.1
)

require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
)
2 changes: 2 additions & 0 deletions crates/yavashark_test262/runner/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
151 changes: 151 additions & 0 deletions crates/yavashark_test262/runner/progress/progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package progress

import (
"fmt"
"sync"
"sync/atomic"
"yavashark_test262_runner/status"
)

const (
ColorGreen = "\033[32m"
ColorRed = "\033[31m"
ColorYellow = "\033[33m"
ColorBlue = "\033[34m"
ColorMagenta = "\033[35m"
ColorCyan = "\033[36m"
ColorReset = "\033[0m"
ColorGray = "\033[90m"
)

type ProgressTracker struct {
mu sync.Mutex

passed atomic.Uint32
failed atomic.Uint32
skipped atomic.Uint32
timeout atomic.Uint32
crashed atomic.Uint32
parseError atomic.Uint32
parseSuccessError atomic.Uint32
notImplemented atomic.Uint32
runnerError atomic.Uint32
total atomic.Uint32
lastPrintedProgress atomic.Uint32

totalTests uint32
}

func NewProgressTracker(totalTests uint32) *ProgressTracker {
return &ProgressTracker{
totalTests: totalTests,
}
}

func (pt *ProgressTracker) Add(s status.Status) {
switch s {
case status.PASS:
pt.passed.Add(1)
case status.FAIL:
pt.failed.Add(1)
case status.SKIP:
pt.skipped.Add(1)
case status.TIMEOUT:
pt.timeout.Add(1)
case status.CRASH:
pt.crashed.Add(1)
case status.PARSE_ERROR:
pt.parseError.Add(1)
case status.PARSE_SUCCESS_ERROR:
pt.parseSuccessError.Add(1)
case status.NOT_IMPLEMENTED:
pt.notImplemented.Add(1)
case status.RUNNER_ERROR:
pt.runnerError.Add(1)
}

current := pt.total.Add(1)
pt.updateProgress(current)
}

func (pt *ProgressTracker) updateProgress(current uint32) {
lastPrinted := pt.lastPrintedProgress.Load()

threshold := uint32(100)
if pt.totalTests > 0 {
percentThreshold := pt.totalTests / 50 // 2%
if percentThreshold > threshold {
threshold = percentThreshold
}
}

if current-lastPrinted >= threshold || current == pt.totalTests {
if pt.lastPrintedProgress.CompareAndSwap(lastPrinted, current) {
pt.printProgressBar(current)
}
}
}

func (pt *ProgressTracker) printProgressBar(current uint32) {
passed := pt.passed.Load()
failed := pt.failed.Load()
skipped := pt.skipped.Load()
timeout := pt.timeout.Load()
crashed := pt.crashed.Load()

barWidth := 50
passedWidth := int(float64(passed) / float64(current) * float64(barWidth))
failedWidth := int(float64(failed) / float64(current) * float64(barWidth))
skippedWidth := int(float64(skipped) / float64(current) * float64(barWidth))
timeoutWidth := int(float64(timeout) / float64(current) * float64(barWidth))
crashedWidth := int(float64(crashed) / float64(current) * float64(barWidth))
otherWidth := barWidth - passedWidth - failedWidth - skippedWidth - timeoutWidth - crashedWidth

bar := ""
if passedWidth > 0 {
bar += ColorGreen + repeatChar("█", passedWidth) + ColorReset
}
if failedWidth > 0 {
bar += ColorRed + repeatChar("█", failedWidth) + ColorReset
}
if timeoutWidth > 0 {
bar += ColorYellow + repeatChar("█", timeoutWidth) + ColorReset
}
if crashedWidth > 0 {
bar += ColorMagenta + repeatChar("█", crashedWidth) + ColorReset
}
if skippedWidth > 0 {
bar += ColorCyan + repeatChar("█", skippedWidth) + ColorReset
}
if otherWidth > 0 {
bar += ColorGray + repeatChar("░", otherWidth) + ColorReset
}

percentage := float64(current) / float64(pt.totalTests) * 100

fmt.Printf("\r[%s] %3d%% (%d/%d) | %sP:%d%s %sF:%d%s %sT:%d%s %sC:%d%s %sS:%d%s",
bar,
int(percentage),
current,
pt.totalTests,
ColorGreen, passed, ColorReset,
ColorRed, failed, ColorReset,
ColorYellow, timeout, ColorReset,
ColorMagenta, crashed, ColorReset,
ColorCyan, skipped, ColorReset,
)
}

func (pt *ProgressTracker) GetStats() (passed, failed, skipped, timeout, crashed, parseError, parseSuccessError, notImplemented, runnerError, total uint32) {
return pt.passed.Load(), pt.failed.Load(), pt.skipped.Load(), pt.timeout.Load(), pt.crashed.Load(),
pt.parseError.Load(), pt.parseSuccessError.Load(), pt.notImplemented.Load(), pt.runnerError.Load(),
pt.total.Load()
}

func repeatChar(char string, count int) string {
result := ""
for i := 0; i < count; i++ {
result += char
}
return result
}
124 changes: 124 additions & 0 deletions crates/yavashark_test262/runner/results/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import (
"yavashark_test262_runner/status"
)

const (
ColorGreen = "\033[32m"
ColorRed = "\033[31m"
ColorYellow = "\033[33m"
ColorBlue = "\033[34m"
ColorMagenta = "\033[35m"
ColorCyan = "\033[36m"
ColorReset = "\033[0m"
ColorBold = "\033[1m"
ColorDim = "\033[2m"
)

type TestResults struct {
TestResults []Result
Passed uint32
Expand Down Expand Up @@ -212,7 +224,119 @@ func (tr *TestResults) Compare(other *TestResults) {
printDiff("Timeout", tr.Timeout, other.Timeout, tr.Total)
printDiff("Parse Error", tr.ParseError, other.ParseError, tr.Total)
printDiff("Total", tr.Total, other.Total, tr.Total)
}

func (tr *TestResults) PrintResultsWithDiff(other *TestResults) {
fmt.Printf("\n%s=== Test Results Summary ===%s\n\n", ColorBold, ColorReset)

fmt.Printf("%sCurrent Run:%s\n", ColorBold, ColorReset)
tr.printResultsLine("Passed", tr.Passed, tr.Total, other.Passed)
tr.printResultsLine("Failed", tr.Failed, tr.Total, other.Failed)
tr.printResultsLine("Timeout", tr.Timeout, tr.Total, other.Timeout)
tr.printResultsLine("Crashed", tr.Crashed, tr.Total, other.Crashed)
tr.printResultsLine("Skipped", tr.Skipped, tr.Total, other.Skipped)
tr.printResultsLine("Not Implemented", tr.NotImplemented, tr.Total, other.NotImplemented)
tr.printResultsLine("Runner Error", tr.RunnerError, tr.Total, other.RunnerError)
tr.printResultsLine("Parse Error", tr.ParseError, tr.Total, other.ParseError)
tr.printResultsLine("Parse Success Error", tr.ParseSuccessError, tr.Total, other.ParseSuccessError)

fmt.Printf("\n%sTotal: %d%s\n", ColorBold, tr.Total, ColorReset)

fmt.Printf("\n%s=== Net Changes ===%s\n", ColorBold, ColorReset)
netPassed := int32(tr.Passed) - int32(other.Passed)
netFailed := int32(tr.Failed) - int32(other.Failed)
netTimeout := int32(tr.Timeout) - int32(other.Timeout)
netCrashed := int32(tr.Crashed) - int32(other.Crashed)

if netPassed != 0 {
if netPassed > 0 {
fmt.Printf("%s✓ Passed: +%d%s (gained)\n", ColorGreen, netPassed, ColorReset)
} else {
fmt.Printf("%s✗ Passed: %d%s (lost)\n", ColorRed, netPassed, ColorReset)
}
}

if netFailed != 0 {
if netFailed > 0 {
fmt.Printf("%s✗ Failed: +%d%s (gained)\n", ColorRed, netFailed, ColorReset)
} else {
fmt.Printf("%s✓ Failed: %d%s (improved)\n", ColorGreen, netFailed, ColorReset)
}
}

if netTimeout != 0 {
if netTimeout > 0 {
fmt.Printf("%s⏱ Timeout: +%d%s (gained)\n", ColorYellow, netTimeout, ColorReset)
} else {
fmt.Printf("%s✓ Timeout: %d%s (improved)\n", ColorGreen, netTimeout, ColorReset)
}
}

if netCrashed != 0 {
if netCrashed > 0 {
fmt.Printf("%s💥 Crashed: +%d%s (gained)\n", ColorMagenta, netCrashed, ColorReset)
} else {
fmt.Printf("%s✓ Crashed: %d%s (improved)\n", ColorGreen, netCrashed, ColorReset)
}
}

// Overall summary
fmt.Printf("\n%s=== Overall Summary ===%s\n", ColorBold, ColorReset)
totalChanges := abs(netPassed) + abs(netFailed) + abs(netTimeout) + abs(netCrashed)
if totalChanges > 0 {
fmt.Printf("Total test status changes: %d\n", totalChanges)

passedGained := 0
if netPassed > 0 {
passedGained = int(netPassed)
}
failedLost := 0
if netFailed < 0 {
failedLost = int(-netFailed)
}
improvements := passedGained + failedLost

if improvements > 0 {
fmt.Printf("%s↑ Improvements: %d%s\n", ColorGreen, improvements, ColorReset)
}

failedGained := 0
if netFailed > 0 {
failedGained = int(netFailed)
}
passedLost := 0
if netPassed < 0 {
passedLost = int(-netPassed)
}
regressions := failedGained + passedLost

if regressions > 0 {
fmt.Printf("%s↓ Regressions: %d%s\n", ColorRed, regressions, ColorReset)
}
} else {
fmt.Printf("%sNo changes from previous run%s\n", ColorDim, ColorReset)
}
}

func (tr *TestResults) printResultsLine(name string, current, total, previous uint32) {
percentage := float64(current) / float64(total) * 100
diff := int32(current) - int32(previous)

var diffStr string
if diff > 0 {
diffStr = fmt.Sprintf(" %s(+%d)%s", ColorGreen, diff, ColorReset)
} else if diff < 0 {
diffStr = fmt.Sprintf(" %s(%d)%s", ColorRed, diff, ColorReset)
}

fmt.Printf(" %s: %d (%.2f%%)%s\n", name, current, percentage, diffStr)
}

func abs(n int32) int32 {
if n < 0 {
return -n
}
return n
}

func printDiff(name string, n1 uint32, n2 uint32, total uint32) {
Expand Down
Loading
Loading