Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: fix join_path and join_path_singe to respect absolute paths #21752

Closed
wants to merge 5 commits into from
Closed

os: fix join_path and join_path_singe to respect absolute paths #21752

wants to merge 5 commits into from

Conversation

mike-ward
Copy link
Contributor

Fixes issue #21751 where by absolute paths in second and subsequent arguments in join_path and join_path_single were treated as relative paths instead of absolute paths.

Required changing several tests in join_path_text.v, which made incorrect assertions about join_path responses.

@@ -26,7 +26,7 @@ fn test_join_path() {
assert os.join_path('foo/bar', './file.txt') == r'foo\bar\file.txt'
assert os.join_path('/opt/v', './x') == r'\opt\v\x'
assert os.join_path('v', 'foo/bar', 'dir') == r'v\foo\bar\dir'
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'v\foo\bar\baz\dir'
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'/dir'
Copy link
Contributor

@JalonSolov JalonSolov Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be r'v\foo\bar\baz\dir'?

@@ -40,14 +40,14 @@ fn test_join_path() {
assert os.join_path('foo/bar', './file.txt') == 'foo/bar/file.txt'
assert os.join_path('/opt/v', './x') == '/opt/v/x'
assert os.join_path('/foo/bar', './.././file.txt') == '/foo/bar/../file.txt'
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'v/foo/bar/baz/dir'
assert os.join_path('v', 'foo/bar\\baz', '/dir') == '/dir'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here v/foo/bar/baz/dir.

}
}

fn test_join_path_single() {
assert os.join_path_single('', '') == ''
assert os.join_path_single('', './b') == 'b'
assert os.join_path_single('', '/b') == 'b'
assert os.join_path_single('', '/b') == '/b'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be r'/b' instead.

@spytheman
Copy link
Member

The later arguments to join_path are relative and not absolute.

@spytheman spytheman closed this Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants