ci: make test_execute in os_test.v more robust
parent
1c17ba82ac
commit
c6b8b0bb0a
|
@ -842,21 +842,21 @@ fn test_expand_tilde_to_home() {
|
||||||
assert os.expand_tilde_to_home('~') == os.home_dir()
|
assert os.expand_tilde_to_home('~') == os.home_dir()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_execute() {
|
fn test_execute() ? {
|
||||||
$if !linux {
|
print0script := os.join_path(tfolder, 'print0.v')
|
||||||
return
|
|
||||||
}
|
|
||||||
// The output of the next command contains a 0 byte in the middle.
|
// The output of the next command contains a 0 byte in the middle.
|
||||||
// Nevertheless, the execute function *should* return a string that
|
// Nevertheless, the execute function *should* return a string that
|
||||||
// contains it. NB: TERM, SHELL and HOME are used here, because they are
|
// contains it.
|
||||||
// very likely to be present, unlike LANGUAGE and LANG.
|
os.write_file(print0script, 'C.printf(c"start%cMIDDLE%cfinish\nxx", 0, 0)\n') ?
|
||||||
result := os.execute('printenv --null TERM SHELL HOME')
|
defer {
|
||||||
hexresult := result.output.bytes().hex()
|
os.rm(print0script) or {}
|
||||||
println('exit_code: $result.exit_code')
|
}
|
||||||
println('output: |$result.output|')
|
result := os.execute('"' + @VEXE + '" run "$print0script"')
|
||||||
println('output.len: $result.output.len')
|
hexresult := result.output.bytes().hex()
|
||||||
println('output hexresult: $hexresult')
|
// println('exit_code: $result.exit_code')
|
||||||
assert result.exit_code == 0
|
// println('output: |$result.output|')
|
||||||
assert result.output.len > 0
|
// println('output.len: $result.output.len')
|
||||||
assert hexresult.contains('002f')
|
// println('output hexresult: $hexresult')
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert hexresult == '7374617274004d4944444c450066696e6973680a7878'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue