@@ -899,7 +899,9 @@ def test_install_libraries_from_path(capsys, monkeypatch, mocker, path_exists, l
899
899
joinpath_calls .append (unittest .mock .call (libraries_path , expected_destination_name ))
900
900
symlink_to_calls .append (
901
901
unittest .mock .call (symlink_source_path ,
902
- target = library [compilesketches .CompileSketches .dependency_source_path_key ],
902
+ target = compilesketches .absolute_path (
903
+ library [compilesketches .CompileSketches .dependency_source_path_key ]
904
+ ),
903
905
target_is_directory = True ))
904
906
905
907
# noinspection PyUnresolvedReferences
@@ -1500,22 +1502,47 @@ def test_parse_boolean_input(boolean_input, expected_output):
1500
1502
assert compilesketches .parse_boolean_input (boolean_input = boolean_input ) == expected_output
1501
1503
1502
1504
1503
- def test_path_relative_to_workspace (monkeypatch ):
1505
+ @pytest .mark .parametrize ("path, expected_relative_path" ,
1506
+ # Path under workspace
1507
+ [("/fooWorkspace/baz" , pathlib .PurePath ("baz" )),
1508
+ # Path outside workspace
1509
+ ("/bar/foo" , pathlib .Path ("/" ).resolve ().joinpath ("bar" , "foo" ))])
1510
+ def test_path_relative_to_workspace (monkeypatch , path , expected_relative_path ):
1504
1511
monkeypatch .setenv ("GITHUB_WORKSPACE" , "/fooWorkspace" )
1505
1512
1506
- assert compilesketches .path_relative_to_workspace (path = pathlib .PurePath ("/fooWorkspace" , "baz" )
1507
- ) == pathlib .PurePath ("baz" )
1508
- assert compilesketches .path_relative_to_workspace (path = "/fooWorkspace/baz" ) == pathlib .PurePath ("baz" )
1509
- # Test path outside workspace
1510
- assert compilesketches .path_relative_to_workspace (path = "/bar/foo" ) == pathlib .PurePath ("/bar/foo" )
1513
+ assert compilesketches .path_relative_to_workspace (path = path ) == expected_relative_path
1514
+ assert compilesketches .path_relative_to_workspace (path = pathlib .PurePath (path )) == expected_relative_path
1511
1515
1512
1516
1513
- @pytest .mark .parametrize ("path, expected_absolute_path" , [("/asdf" , "/asdf" ), ("asdf" , "/fooWorkspace/asdf" )])
1517
+ @pytest .mark .parametrize ("path, expected_absolute_path" ,
1518
+ # Absolute path
1519
+ [("/asdf" , pathlib .Path ("/" ).resolve ().joinpath ("asdf" )),
1520
+ # Relative path
1521
+ ("asdf" , pathlib .Path ("/" ).resolve ().joinpath ("fooWorkspace" , "asdf" )),
1522
+ # Use of ~
1523
+ ("~/foo" , pathlib .Path .home ().joinpath ("foo" )),
1524
+ # Use of ..
1525
+ ("/foo/bar/../baz" , pathlib .Path ("/" ).resolve ().joinpath ("foo" , "baz" ))
1526
+ ])
1514
1527
def test_absolute_path (monkeypatch , path , expected_absolute_path ):
1515
1528
monkeypatch .setenv ("GITHUB_WORKSPACE" , "/fooWorkspace" )
1516
1529
1517
- assert compilesketches .absolute_path (path = path ) == pathlib .PurePath (expected_absolute_path )
1518
- assert compilesketches .absolute_path (path = pathlib .PurePath (path )) == pathlib .PurePath (expected_absolute_path )
1530
+ assert compilesketches .absolute_path (path = path ) == expected_absolute_path
1531
+ assert compilesketches .absolute_path (path = pathlib .PurePath (path )) == expected_absolute_path
1532
+
1533
+
1534
+ @pytest .mark .parametrize (
1535
+ "path, expected_path" ,
1536
+ [("foo/bar-relative-path" , pathlib .PurePath ("foo/bar-relative-path" )),
1537
+ ("/foo/bar-absolute-path" , pathlib .Path ("/" ).resolve ().joinpath ("foo" , "bar-absolute-path" ))]
1538
+ )
1539
+ def test_absolute_relative_path_conversion (monkeypatch , path , expected_path ):
1540
+ monkeypatch .setenv ("GITHUB_WORKSPACE" , "/fooWorkspace" )
1541
+ assert compilesketches .path_relative_to_workspace (
1542
+ path = compilesketches .absolute_path (
1543
+ path = path
1544
+ )
1545
+ ) == expected_path
1519
1546
1520
1547
1521
1548
def test_list_to_string ():
0 commit comments