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

tests: add tests for -d debug, -cg, -g in combination for [if debug]fn etc

This commit is contained in:
Delyan Angelov 2021-03-07 12:42:30 +02:00
parent 64bc2fb40a
commit f1c4e962f4
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
8 changed files with 50 additions and 7 deletions

View File

@ -0,0 +1,3 @@
main with debug
foo, x: 123
done

View File

@ -0,0 +1,3 @@
foo, x: 123
bar, x: 456
done

View File

@ -0,0 +1,2 @@
foo, x: 123
done

View File

@ -0,0 +1,3 @@
main with debug
foo, x: 123
done

View File

@ -0,0 +1 @@
done

View File

@ -0,0 +1,18 @@
[if debug]
fn foo(x int) {
println('foo, x: $x')
}
[if bar]
fn bar(x int) {
println('bar, x: $x')
}
fn main() {
$if debug {
println('main with debug')
}
foo(123) // will not be called if `-d debug` is not passed
bar(456) // will not be called if `-d bar` is not passed
println('done')
}

View File

@ -8,7 +8,7 @@ import runtime
import benchmark
const skip_files = [
'vlib/v/checker/tests/custom_comptime_define_if_flag.vv',
'non_existing.vv' /* minimize commit diff churn, do not remove */,
]
const skip_on_ubuntu_musl = [
@ -74,12 +74,6 @@ fn test_all() {
tasks.add('', parser_dir, '-prod', '.out', parser_tests, false)
tasks.add('', checker_dir, '-prod', '.out', checker_tests, false)
tasks.add('', scanner_dir, '-prod', '.out', scanner_tests, false)
tasks.add('', checker_dir, '-d mysymbol run', '.mysymbol.run.out', ['custom_comptime_define_error.vv'],
false)
tasks.add('', checker_dir, '-d mydebug run', '.mydebug.run.out', ['custom_comptime_define_if_flag.vv'],
false)
tasks.add('', checker_dir, '-d nodebug run', '.nodebug.run.out', ['custom_comptime_define_if_flag.vv'],
false)
tasks.add('', checker_dir, '--enable-globals run', '.run.out', ['globals_error.vv'],
false)
tasks.add('', global_dir, '--enable-globals', '.out', global_tests, false)
@ -118,6 +112,25 @@ fn test_all() {
'.var_invalid.run.out', ['using_comptime_env.vv'], false)
cte_tasks.run()
}
mut ct_tasks := Tasks{
vexe: vexe
parallel_jobs: 1
label: 'comptime define tests'
}
ct_tasks.add_checked_run('-d mysymbol run', '.mysymbol.run.out', ['custom_comptime_define_error.vv'])
ct_tasks.add_checked_run('-d mydebug run', '.mydebug.run.out', ['custom_comptime_define_if_flag.vv'])
ct_tasks.add_checked_run('-d nodebug run', '.nodebug.run.out', ['custom_comptime_define_if_flag.vv'])
ct_tasks.add_checked_run('run', '.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-g run', '.g.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-cg run', '.cg.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-d debug run', '.debug.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.add_checked_run('-d debug -d bar run', '.debug.bar.run.out', ['custom_comptime_define_if_debug.vv'])
ct_tasks.run()
}
fn (mut tasks Tasks) add_checked_run(voptions string, result_extension string, tests []string) {
checker_dir := 'vlib/v/checker/tests'
tasks.add('', checker_dir, voptions, result_extension, tests, false)
}
fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {