You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetEdk2RelativePathFromAbsolutePath() is currently defined as follows:
"""Given an absolute path return a edk2 path relative to workspace or packagespath. Note: absolute path must be in the OS specific path form Note: the relative path will be in POSIX-like path form Args: abspath (os.PathLike): absolute path to a file or directory. Path must contain OS specific separator. Returns: (os.PathLike): POSIX-like relative path to workspace or packagespath (None): abspath is none (None): path is not valid """
It requires an OS-specific path (to the current OS) to be given as input. However, it does not return an exception or other fail in a well-defined way if path given does not conform to the current OS. It likely returns a non-POSIX path.
So, this is not a bug with the function in the case the user passes the expected path format but a bug in validating the function input values.
Reproduction steps
The following code demonstrates the problem if run on Linux since it passes a Windows style path to the function.
p = f"{ws_pkg_abs}\\module_2\\X64\\TestFile.inf"
expected_rel_from_abs_path = PurePath(os.path.join(ws_p_name, "module_2", "X64", "TestFile.inf")).as_posix()
actual_rel_from_abs_path = pathobj.GetEdk2RelativePathFromAbsolutePath(p)
> self.assertEqual(expected_rel_from_abs_path, actual_rel_from_abs_path)
E AssertionError: 'WSTestPkg/module_2/X64/TestFile.inf' != 'WSTestPkg\\module_2\\X64\\TestFile.inf'
E - WSTestPkg/module_2/X64/TestFile.inf
E ? ^ ^ ^
E + WSTestPkg\module_2\X64\TestFile.inf
Expected behavior
The function should ensure that it handles input in a predictable and well-defined manner.
Execution Environment
No response
Pip packages
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Contact Details
No response
Describe the Bug
GetEdk2RelativePathFromAbsolutePath() is currently defined as follows:
It requires an OS-specific path (to the current OS) to be given as input. However, it does not return an exception or other fail in a well-defined way if path given does not conform to the current OS. It likely returns a non-POSIX path.
So, this is not a bug with the function in the case the user passes the expected path format but a bug in validating the function input values.
Reproduction steps
The following code demonstrates the problem if run on Linux since it passes a Windows style path to the function.
Expected behavior
The function should ensure that it handles input in a predictable and well-defined manner.
Execution Environment
No response
Pip packages
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: