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:
parent
64bc2fb40a
commit
f1c4e962f4
@ -0,0 +1,3 @@
|
|||||||
|
main with debug
|
||||||
|
foo, x: 123
|
||||||
|
done
|
@ -0,0 +1,3 @@
|
|||||||
|
foo, x: 123
|
||||||
|
bar, x: 456
|
||||||
|
done
|
@ -0,0 +1,2 @@
|
|||||||
|
foo, x: 123
|
||||||
|
done
|
@ -0,0 +1,3 @@
|
|||||||
|
main with debug
|
||||||
|
foo, x: 123
|
||||||
|
done
|
@ -0,0 +1 @@
|
|||||||
|
done
|
18
vlib/v/checker/tests/custom_comptime_define_if_debug.vv
Normal file
18
vlib/v/checker/tests/custom_comptime_define_if_debug.vv
Normal 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')
|
||||||
|
}
|
@ -8,7 +8,7 @@ import runtime
|
|||||||
import benchmark
|
import benchmark
|
||||||
|
|
||||||
const skip_files = [
|
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 = [
|
const skip_on_ubuntu_musl = [
|
||||||
@ -74,12 +74,6 @@ fn test_all() {
|
|||||||
tasks.add('', parser_dir, '-prod', '.out', parser_tests, false)
|
tasks.add('', parser_dir, '-prod', '.out', parser_tests, false)
|
||||||
tasks.add('', checker_dir, '-prod', '.out', checker_tests, false)
|
tasks.add('', checker_dir, '-prod', '.out', checker_tests, false)
|
||||||
tasks.add('', scanner_dir, '-prod', '.out', scanner_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'],
|
tasks.add('', checker_dir, '--enable-globals run', '.run.out', ['globals_error.vv'],
|
||||||
false)
|
false)
|
||||||
tasks.add('', global_dir, '--enable-globals', '.out', global_tests, 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)
|
'.var_invalid.run.out', ['using_comptime_env.vv'], false)
|
||||||
cte_tasks.run()
|
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) {
|
fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user