tools/check-md: minor cleanup (#7940)
parent
085085a2b9
commit
6c013023fc
|
@ -176,6 +176,11 @@ fn (mut f MDFile) dump() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_fmt_exit_code(vfile string, vexe string) int {
|
||||||
|
res := os.exec('"$vexe" fmt -verify $vfile') or { return 1 }
|
||||||
|
return res.exit_code
|
||||||
|
}
|
||||||
|
|
||||||
fn (mut f MDFile) check_examples() (int, int) {
|
fn (mut f MDFile) check_examples() (int, int) {
|
||||||
mut errors := 0
|
mut errors := 0
|
||||||
mut oks := 0
|
mut oks := 0
|
||||||
|
@ -197,11 +202,11 @@ fn (mut f MDFile) check_examples() (int, int) {
|
||||||
mut acommands := e.command.split(' ')
|
mut acommands := e.command.split(' ')
|
||||||
nofmt := 'nofmt' in acommands
|
nofmt := 'nofmt' in acommands
|
||||||
for command in acommands {
|
for command in acommands {
|
||||||
|
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
|
||||||
match command {
|
match command {
|
||||||
'compile' {
|
'compile' {
|
||||||
res := os.system('"$vexe" -w -Wfatal-errors -o x.c $vfile')
|
res := os.system('"$vexe" -w -Wfatal-errors -o x.c $vfile')
|
||||||
os.rm('x.c') or { }
|
os.rm('x.c') or { }
|
||||||
fmt_res := if nofmt { 0 } else { os.system('"$vexe" fmt -verify $vfile') }
|
|
||||||
if res != 0 || fmt_res != 0 {
|
if res != 0 || fmt_res != 0 {
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
eprintln(eline(f.path, e.sline, 0, 'example failed to compile'))
|
eprintln(eline(f.path, e.sline, 0, 'example failed to compile'))
|
||||||
|
@ -218,7 +223,6 @@ fn (mut f MDFile) check_examples() (int, int) {
|
||||||
}
|
}
|
||||||
'live' {
|
'live' {
|
||||||
res := os.system('"$vexe" -w -Wfatal-errors -live -o x.c $vfile')
|
res := os.system('"$vexe" -w -Wfatal-errors -live -o x.c $vfile')
|
||||||
fmt_res := if nofmt { 0 } else { os.system('"$vexe" fmt -verify $vfile') }
|
|
||||||
if res != 0 || fmt_res != 0 {
|
if res != 0 || fmt_res != 0 {
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
eprintln(eline(f.path, e.sline, 0, 'example failed to compile with -live'))
|
eprintln(eline(f.path, e.sline, 0, 'example failed to compile with -live'))
|
||||||
|
@ -247,7 +251,6 @@ fn (mut f MDFile) check_examples() (int, int) {
|
||||||
}
|
}
|
||||||
'oksyntax' {
|
'oksyntax' {
|
||||||
res := os.system('"$vexe" -w -Wfatal-errors -check-syntax $vfile')
|
res := os.system('"$vexe" -w -Wfatal-errors -check-syntax $vfile')
|
||||||
fmt_res := if nofmt { 0 } else { os.system('"$vexe" fmt -verify $vfile') }
|
|
||||||
if res != 0 || fmt_res != 0 {
|
if res != 0 || fmt_res != 0 {
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
eprintln(eline(f.path, e.sline, 0, '`oksyntax` example with invalid syntax'))
|
eprintln(eline(f.path, e.sline, 0, '`oksyntax` example with invalid syntax'))
|
||||||
|
|
Loading…
Reference in New Issue