Skip to content

Commit

Permalink
improve failing test output, add a summary
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Oct 1, 2024
1 parent d645c5b commit a40dbf6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 13 additions & 7 deletions go2v_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ import strings
import os

fn test_all() {
mut subdir := 'tests'
subdir := 'tests'
mut app := &App{
sb: strings.new_builder(1000)
}

// All tests
mut test_names := os.ls('tests') or { return }
test_names.sort()
mut tests_ok := true
mut tests_failures := []string{}
for test_name in test_names {
println('===========================================')
println('='.repeat(44))
create_json(subdir, test_name)
// A separate instance for each test
mut app2 := &App{
sb: strings.new_builder(1000)
}
app2.run_test(subdir, test_name) or {
eprintln('Error running test ${test_name}: ${err}')
break
exit(1)
}
if !app2.tests_ok {
tests_failures << test_name
}
tests_ok &&= app2.tests_ok
}
// if !app.tests_ok {
if !tests_ok {
if tests_failures.len != 0 {
eprintln('='.repeat(80))
eprintln('Found ${tests_failures.len} go2v errors. Use the following commands to reproduce them in isolation:')
for f in tests_failures {
eprintln(' ./go2v ${subdir}/${f}')
}
exit(1)
}
}
4 changes: 4 additions & 0 deletions main.v
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ fn (mut app App) typ(t Type) {
}

fn generate_ast_for_go_file(go_file_path string) string {
if !os.exists(go_file_path) {
eprintln('Missing input .go file: `${go_file_path}`.')
return ''
}
output_file := go_file_path + '.json'

asty_cmd := '${full_path_to_asty} go2json -comments -indent 2 -input ${go_file_path} -output ${output_file}'
Expand Down

0 comments on commit a40dbf6

Please sign in to comment.