From 471c931adad46c1eddf5e27e925739e61e3a299d Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 14 Jun 2020 01:41:47 +0200 Subject: [PATCH] os: do not trim space from output of exec --- cmd/tools/vrepl.v | 2 +- vlib/os/os_nix.c.v | 2 +- vlib/v/tests/prod/assoc.prod.v.expected.txt | 2 +- vlib/v/tests/repl/repl_test.v | 2 +- vlib/v/tests/repl/runner/runner.v | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index 36c4e1683c..f32f4f4dec 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -258,7 +258,7 @@ fn run_repl(workdir string, vrepl_prefix string) { } fn print_output(s os.Result) { - lines := s.output.split('\n') + lines := s.output.trim_right('\n\r').split('\n') for line in lines { if line.contains('.vrepl_temp.v:') { // Hide the temporary file name diff --git a/vlib/os/os_nix.c.v b/vlib/os/os_nix.c.v index 93ba3726ab..a62d0c74d9 100644 --- a/vlib/os/os_nix.c.v +++ b/vlib/os/os_nix.c.v @@ -113,7 +113,7 @@ pub fn exec(cmd string) ?Result { bufbp := byteptr(buf) res.write_bytes( bufbp, vstrlen(bufbp) ) } - soutput := res.str().trim_space() + soutput := res.str() //res.free() exit_code := vpclose(f) // if exit_code != 0 { diff --git a/vlib/v/tests/prod/assoc.prod.v.expected.txt b/vlib/v/tests/prod/assoc.prod.v.expected.txt index 432b232bf3..823b1e5929 100644 --- a/vlib/v/tests/prod/assoc.prod.v.expected.txt +++ b/vlib/v/tests/prod/assoc.prod.v.expected.txt @@ -1,3 +1,3 @@ MyStruct { s: '6' -} \ No newline at end of file +} diff --git a/vlib/v/tests/repl/repl_test.v b/vlib/v/tests/repl/repl_test.v index e4858a7a12..ac8a7248fe 100644 --- a/vlib/v/tests/repl/repl_test.v +++ b/vlib/v/tests/repl/repl_test.v @@ -21,7 +21,7 @@ fn test_the_v_compiler_can_be_invoked() { } // println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output') assert r_error.exit_code == 1 - assert r_error.output == "builder error: nonexisting.v doesn't exist" + assert r_error.output.trim_space() == "builder error: nonexisting.v doesn't exist" } struct Session { diff --git a/vlib/v/tests/repl/runner/runner.v b/vlib/v/tests/repl/runner/runner.v index 70499840e3..2729b899a0 100644 --- a/vlib/v/tests/repl/runner/runner.v +++ b/vlib/v/tests/repl/runner/runner.v @@ -44,7 +44,7 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string { fcontent := os.read_file(file) or { return error('Could not read file ${file}') } content := fcontent.replace('\r', '') input := content.all_before('===output===\n') - output := content.all_after('===output===\n') + output := content.all_after('===output===\n').trim_right('\n\r') fname := os.file_name( file ) @@ -66,6 +66,7 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string { .replace(wd + os.path_separator, '' ) .replace(vexec_folder, '') .replace('\\', '/') + .trim_right('\n\r') if result != output { file_result := '${file}.result.txt'