ci: fix coutput_test.v on windows by fixing `-o -` on windows
parent
6068777e03
commit
33e4dc3ad3
|
@ -479,7 +479,7 @@ fn (mut v Builder) cc() {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if v.pref.out_name.ends_with('/-') {
|
if v.pref.should_output_to_stdout() {
|
||||||
// output to stdout
|
// output to stdout
|
||||||
content := os.read_file(v.out_name_c) or { panic(err) }
|
content := os.read_file(v.out_name_c) or { panic(err) }
|
||||||
println(content)
|
println(content)
|
||||||
|
|
|
@ -107,7 +107,7 @@ fn (mut b Builder) run_compiled_executable_and_exit() {
|
||||||
if b.pref.only_check_syntax {
|
if b.pref.only_check_syntax {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if b.pref.out_name.ends_with('/-') {
|
if b.pref.should_output_to_stdout() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if b.pref.os == .ios {
|
if b.pref.os == .ios {
|
||||||
|
|
|
@ -12,15 +12,7 @@ const testdata_folder = os.join_path(vroot, 'vlib', 'v', 'gen', 'c', 'testdata')
|
||||||
|
|
||||||
const diff_cmd = diff.find_working_diff_command() or { '' }
|
const diff_cmd = diff.find_working_diff_command() or { '' }
|
||||||
|
|
||||||
fn test_windows() ? {
|
|
||||||
$if windows {
|
|
||||||
eprintln('this test can not run on windows for now')
|
|
||||||
exit(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_out_files() ? {
|
fn test_out_files() ? {
|
||||||
eprintln('> vroot: $vroot')
|
|
||||||
println(term.colorize(term.green, '> testing whether .out files match:'))
|
println(term.colorize(term.green, '> testing whether .out files match:'))
|
||||||
os.chdir(vroot)
|
os.chdir(vroot)
|
||||||
output_path := os.join_path(os.temp_dir(), 'coutput', 'out')
|
output_path := os.join_path(os.temp_dir(), 'coutput', 'out')
|
||||||
|
@ -41,7 +33,7 @@ fn test_out_files() ? {
|
||||||
print(term.colorize(term.magenta, 'v run $relpath') + ' == ' +
|
print(term.colorize(term.magenta, 'v run $relpath') + ' == ' +
|
||||||
term.colorize(term.magenta, out_relpath) + ' ')
|
term.colorize(term.magenta, out_relpath) + ' ')
|
||||||
pexe := os.join_path(output_path, '${basename}.exe')
|
pexe := os.join_path(output_path, '${basename}.exe')
|
||||||
compilation := os.execute('VCOLORS=never $vexe -o $pexe $path')
|
compilation := os.execute('$vexe -o $pexe $path')
|
||||||
ensure_compilation_succeeded(compilation)
|
ensure_compilation_succeeded(compilation)
|
||||||
res := os.execute(pexe)
|
res := os.execute(pexe)
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
|
@ -108,7 +100,7 @@ fn test_c_must_have_files() ? {
|
||||||
basename, path, relpath, must_have_relpath := target2paths(must_have_path, '.c.must_have')
|
basename, path, relpath, must_have_relpath := target2paths(must_have_path, '.c.must_have')
|
||||||
print(term.colorize(term.magenta, 'v -o - $relpath') + ' matches all line paterns in ' +
|
print(term.colorize(term.magenta, 'v -o - $relpath') + ' matches all line paterns in ' +
|
||||||
term.colorize(term.magenta, must_have_relpath) + ' ')
|
term.colorize(term.magenta, must_have_relpath) + ' ')
|
||||||
compilation := os.execute('VCOLORS=never $vexe -o - $path')
|
compilation := os.execute('$vexe -o - $path')
|
||||||
ensure_compilation_succeeded(compilation)
|
ensure_compilation_succeeded(compilation)
|
||||||
expected_lines := os.read_lines(must_have_path) or { [] }
|
expected_lines := os.read_lines(must_have_path) or { [] }
|
||||||
generated_c_lines := compilation.output.split_into_lines()
|
generated_c_lines := compilation.output.split_into_lines()
|
||||||
|
@ -128,6 +120,9 @@ fn test_c_must_have_files() ? {
|
||||||
}
|
}
|
||||||
if nmatches == expected_lines.len {
|
if nmatches == expected_lines.len {
|
||||||
println(term.green('OK'))
|
println(term.green('OK'))
|
||||||
|
} else {
|
||||||
|
eprintln('> ALL lines:')
|
||||||
|
eprintln(compilation.output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert total_errors == 0
|
assert total_errors == 0
|
||||||
|
@ -154,8 +149,10 @@ fn normalize_panic_message(message string, vroot string) string {
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vroot_relative(path string) string {
|
fn vroot_relative(opath string) string {
|
||||||
return path.replace(os.path_separator, '/').replace('$vroot/', '').replace('./', '')
|
nvroot := vroot.replace(os.path_separator, '/') + '/'
|
||||||
|
npath := opath.replace(os.path_separator, '/')
|
||||||
|
return npath.replace(nvroot, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_compilation_succeeded(compilation os.Result) {
|
fn ensure_compilation_succeeded(compilation os.Result) {
|
||||||
|
@ -167,23 +164,11 @@ fn ensure_compilation_succeeded(compilation os.Result) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[if etrace ?]
|
|
||||||
fn etrace(msg string) {
|
|
||||||
eprintln(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn target2paths(target_path string, postfix string) (string, string, string, string) {
|
fn target2paths(target_path string, postfix string) (string, string, string, string) {
|
||||||
etrace('')
|
|
||||||
etrace('> target2paths $target_path | postfix: $postfix')
|
|
||||||
basename := os.file_name(target_path).replace(postfix, '')
|
basename := os.file_name(target_path).replace(postfix, '')
|
||||||
etrace(' basename: $basename')
|
|
||||||
target_dir := os.dir(target_path)
|
target_dir := os.dir(target_path)
|
||||||
etrace(' target_dir: $target_dir')
|
|
||||||
path := os.join_path(target_dir, '${basename}.vv')
|
path := os.join_path(target_dir, '${basename}.vv')
|
||||||
etrace(' path: $path')
|
|
||||||
relpath := vroot_relative(path)
|
relpath := vroot_relative(path)
|
||||||
etrace(' relpath: $relpath')
|
|
||||||
target_relpath := vroot_relative(target_path)
|
target_relpath := vroot_relative(target_path)
|
||||||
etrace(' target_relpath: $target_relpath')
|
|
||||||
return basename, path, relpath, target_relpath
|
return basename, path, relpath, target_relpath
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,6 +695,10 @@ pub fn (pref &Preferences) vrun_elog(s string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (pref &Preferences) should_output_to_stdout() bool {
|
||||||
|
return pref.out_name.ends_with('/-') || pref.out_name.ends_with(r'\-')
|
||||||
|
}
|
||||||
|
|
||||||
pub fn arch_from_string(arch_str string) ?Arch {
|
pub fn arch_from_string(arch_str string) ?Arch {
|
||||||
match arch_str {
|
match arch_str {
|
||||||
'amd64', 'x86_64', 'x64', 'x86' { // amd64 recommended
|
'amd64', 'x86_64', 'x64', 'x86' { // amd64 recommended
|
||||||
|
|
Loading…
Reference in New Issue