From c6b8b0bb0ab8210053af44a897fc72d52e0575c3 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 12 Nov 2021 11:24:37 +0200 Subject: [PATCH] ci: make test_execute in os_test.v more robust --- vlib/os/os_test.v | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index 6373a21cb6..683eb80fde 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -842,21 +842,21 @@ fn test_expand_tilde_to_home() { assert os.expand_tilde_to_home('~') == os.home_dir() } -fn test_execute() { - $if !linux { - return - } +fn test_execute() ? { + print0script := os.join_path(tfolder, 'print0.v') // The output of the next command contains a 0 byte in the middle. // Nevertheless, the execute function *should* return a string that - // contains it. NB: TERM, SHELL and HOME are used here, because they are - // very likely to be present, unlike LANGUAGE and LANG. - result := os.execute('printenv --null TERM SHELL HOME') + // contains it. + os.write_file(print0script, 'C.printf(c"start%cMIDDLE%cfinish\nxx", 0, 0)\n') ? + defer { + os.rm(print0script) or {} + } + result := os.execute('"' + @VEXE + '" run "$print0script"') hexresult := result.output.bytes().hex() - println('exit_code: $result.exit_code') - println('output: |$result.output|') - println('output.len: $result.output.len') - println('output hexresult: $hexresult') + // println('exit_code: $result.exit_code') + // println('output: |$result.output|') + // println('output.len: $result.output.len') + // println('output hexresult: $hexresult') assert result.exit_code == 0 - assert result.output.len > 0 - assert hexresult.contains('002f') + assert hexresult == '7374617274004d4944444c450066696e6973680a7878' }