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() {