From 0c922f5570cbed345e12454acdd9ab5d24493d2c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 15 Jun 2021 13:34:28 +0300 Subject: [PATCH] ci: fix the failing os.real_path tests on windows --- vlib/os/os_test.v | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index 9735007588..2c0aca63ad 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -290,7 +290,16 @@ fn test_realpath_of_empty_string_works() { fn test_realpath_non_existing() { non_existing_path := 'sdyfuisd_non_existing_file' - assert os.real_path(non_existing_path) == non_existing_path + rpath := os.real_path(non_existing_path) + $if windows { + // on windows, the workdir is prepended, so the result is absolute: + assert rpath.len > non_existing_path.len + } + $if !windows { + // on unix, the workdir is NOT prepended for now, so the result remains the same. + // TODO: the windows behaviour seems saner, think about normalising the unix case to do the same. + assert os.real_path(non_existing_path) == non_existing_path + } } fn test_realpath_existing() { @@ -322,11 +331,13 @@ fn test_realpath_absolutizes_existing_relative_paths() { assert os.is_abs_path(real_path_of_examples_folder) } -// TODO: think much more about whether this is desirable +// TODO: think much more about whether this is desirable: fn test_realpath_does_not_absolutize_non_existing_relative_paths() { relative_path := os.join_path('one', 'nonexisting_folder', '..', 'something') - assert os.real_path(relative_path).contains('..') - assert os.real_path(relative_path) == relative_path + $if !windows { + assert os.real_path(relative_path).contains('..') + assert os.real_path(relative_path) == relative_path + } } fn test_tmpdir() {