File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,6 +535,7 @@ repo_utils = struct(
535535 mkdir = _mkdir ,
536536 norm_path = _norm_path ,
537537 relative_to = _relative_to ,
538+ is_relative_to = _is_relative_to ,
538539 repo_root_relative_path = _repo_root_relative_path ,
539540 which_checked = _which_checked ,
540541 which_unchecked = _which_unchecked ,
Original file line number Diff line number Diff line change @@ -36,10 +36,18 @@ def _test_relative_to(env):
3636_tests .append (_test_relative_to )
3737
3838def _test_is_relative_to (env ):
39- # Note: `_is_relative_to` isn't publicly exported in `repo_utils` struct natively.
40- # Actually wait, `is_relative_to` is not exported by repo_utils.bzl!
41- # Let's skip testing `_is_relative_to` directly in this suite unless we export it or we don't need to test it directly.
42- pass
39+ mock_mrctx_linux = mocks .rctx (os_name = "linux" )
40+ mock_mrctx_win = mocks .rctx (os_name = "windows" )
41+
42+ # Case-sensitive matching (Linux)
43+ env .expect .that_bool (repo_utils .is_relative_to (mock_mrctx_linux , "foo/bar/baz" , "foo/bar" )).equals (True )
44+ env .expect .that_bool (repo_utils .is_relative_to (mock_mrctx_linux , "foo/bar/baz" , "qux" )).equals (False )
45+
46+ # Case-insensitive matching (Windows)
47+ env .expect .that_bool (repo_utils .is_relative_to (mock_mrctx_win , "C:/Foo/Bar/Baz" , "c:/foo/bar" )).equals (True )
48+ env .expect .that_bool (repo_utils .is_relative_to (mock_mrctx_win , "C:/Foo/Bar/Baz" , "D:/Foo" )).equals (False )
49+
50+ _tests .append (_test_is_relative_to )
4351
4452def repo_utils_test_suite (name ):
4553 """Create the test suite.
You can’t perform that action at this time.
0 commit comments