diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index aaf0164f81..dd6a5bfe50 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -62,6 +62,12 @@ fn get_all_commands() []Command { okmsg: 'V can output a .c file, without compiling further.' rmfile: 'hhww.c' } + $if linux || macos { + res << Command{ + line: '$vexe -o - examples/hello_world.v | grep "#define V_COMMIT_HASH" > /dev/null' + okmsg: 'V prints the generated source code to stdout with `-o -` .' + } + } res << Command{ line: '$vexe -o vtmp cmd/v' okmsg: 'V can compile itself.' @@ -152,7 +158,8 @@ fn (mut cmd Command) run() { sw := time.new_stopwatch({}) cmd.ecode = os.system(cmd.line) spent := sw.elapsed().milliseconds() - println(term_highlight('> Running: "$cmd.line" took: $spent ms.')) + println('> Running: "$cmd.line" took: $spent ms ... ' + + if cmd.ecode != 0 { term.failed('FAILED') } else { term_highlight('OK') }) if vtest_nocleanup { return } diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index ffb8750166..6f867f799a 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -479,6 +479,13 @@ fn (mut v Builder) cc() { } return } + if v.pref.out_name.ends_with('/-') { + // output to stdout + content := os.read_file(v.out_name_c) or { panic(err) } + println(content) + os.rm(v.out_name_c) or {} + return + } // whether to just create a .c or .js file and exit, for example: `v -o v.c cmd.v` ends_with_c := v.pref.out_name.ends_with('.c') ends_with_js := v.pref.out_name.ends_with('.js')