ci: fix the failing os.real_path tests on windows

pull/10453/head
Delyan Angelov 2021-06-15 13:34:28 +03:00
parent 51596da314
commit 0c922f5570
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 15 additions and 4 deletions

View File

@ -290,8 +290,17 @@ fn test_realpath_of_empty_string_works() {
fn test_realpath_non_existing() { fn test_realpath_non_existing() {
non_existing_path := 'sdyfuisd_non_existing_file' non_existing_path := 'sdyfuisd_non_existing_file'
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 assert os.real_path(non_existing_path) == non_existing_path
} }
}
fn test_realpath_existing() { fn test_realpath_existing() {
existing_file_name := 'existing_file.txt' existing_file_name := 'existing_file.txt'
@ -322,12 +331,14 @@ fn test_realpath_absolutizes_existing_relative_paths() {
assert os.is_abs_path(real_path_of_examples_folder) 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() { fn test_realpath_does_not_absolutize_non_existing_relative_paths() {
relative_path := os.join_path('one', 'nonexisting_folder', '..', 'something') relative_path := os.join_path('one', 'nonexisting_folder', '..', 'something')
$if !windows {
assert os.real_path(relative_path).contains('..') assert os.real_path(relative_path).contains('..')
assert os.real_path(relative_path) == relative_path assert os.real_path(relative_path) == relative_path
} }
}
fn test_tmpdir() { fn test_tmpdir() {
t := os.temp_dir() t := os.temp_dir()