From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- v_windows/v/vlib/flag/usage_example_test.v | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 v_windows/v/vlib/flag/usage_example_test.v (limited to 'v_windows/v/vlib/flag/usage_example_test.v') diff --git a/v_windows/v/vlib/flag/usage_example_test.v b/v_windows/v/vlib/flag/usage_example_test.v new file mode 100644 index 0000000..0f6c353 --- /dev/null +++ b/v_windows/v/vlib/flag/usage_example_test.v @@ -0,0 +1,35 @@ +import os + +const the_source = 'vlib/flag/testdata/usage_example.v' + +const the_executable = os.real_path(os.join_path(os.cache_dir(), 'flag_usage_example_app.exe')) + +fn testsuite_begin() { + os.chdir(@VMODROOT) or {} + os.rm(the_executable) or {} + res := os.execute('${@VEXE} -o $the_executable $the_source') + assert res.exit_code == 0 + assert os.execute(the_executable).exit_code == 0 + C.atexit(fn () { + os.rm(the_executable) or {} + }) +} + +fn normalise_lines(lines []string) string { + return '\n' + lines.join('\n') +} + +fn check_program(opts string, extension string) { + result := the_source.replace('.v', extension) + res := os.execute('$the_executable $opts') + assert res.exit_code == 0 + assert normalise_lines(res.output.split_into_lines()) == normalise_lines(os.read_lines(result) or { + panic(err) + }) +} + +fn test_normal_usage() { + check_program('abc def', '.out') + check_program(' --help', '.help.out') + check_program(' --version', '.version.out') +} -- cgit v1.2.3