1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: test bin2v output formatting (#7926)

This commit is contained in:
Lukas Neubert 2021-01-07 21:36:59 +01:00 committed by GitHub
parent 88d18f3303
commit 653121bad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import v.util.vtest
const (
error_missing_vexe = 1
error_failed_tests = 2
b2v_keep_path = os.join_path('vlib', 'v', 'fmt', 'tests', 'bin2v_keep.vv')
)
fn test_fmt() {
@ -28,6 +29,7 @@ fn test_fmt() {
tmpfolder := os.temp_dir()
diff_cmd := util.find_working_diff_command() or { '' }
mut fmt_bench := benchmark.new_benchmark()
fill_bin2v_keep() or { eprintln('failed creating vbin2v_keep.vv: $err') }
keep_input_files := os.walk_ext('vlib/v/fmt/tests', '_keep.vv')
expected_input_files := os.walk_ext('vlib/v/fmt/tests', '_expected.vv')
mut input_files := []string{}
@ -69,6 +71,7 @@ fn test_fmt() {
fmt_bench.ok()
eprintln(fmt_bench.step_message_ok('$vrelpath'))
}
restore_bin2v_placeholder() or { eprintln('failed restoring vbin2v_keep.vv placeholder: $err') }
fmt_bench.stop()
eprintln(term.h_divider('-'))
eprintln(fmt_bench.total_message(fmt_message))
@ -76,3 +79,16 @@ fn test_fmt() {
exit(error_failed_tests)
}
}
fn fill_bin2v_keep() ? {
img0 := os.join_path('tutorials', 'img', 'hello.png')
img1 := os.join_path('tutorials', 'img', 'time.png')
os.rm(b2v_keep_path) ?
os.exec('v bin2v -w $b2v_keep_path $img0 $img1') ?
}
fn restore_bin2v_placeholder() ? {
text := '// This is a placeholder file which will be filled with bin2v output before the test.
// HINT: do NOT delete, move or rename this file!\n'
os.write_file(b2v_keep_path, text) ?
}

View File

@ -0,0 +1,2 @@
// This is a placeholder file which will be filled with bin2v output before the test.
// HINT: do NOT delete, move or rename this file!