Skip to content

Commit 4eb0d25

Browse files
committed
Add test that ensures we can correctly locate and open a data file.
1 parent da225b5 commit 4eb0d25

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/runfiles/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # bu
55
py_test(
66
name = "runfiles_test",
77
srcs = ["runfiles_test.py"],
8+
data = [
9+
"//tests/support:current_build_settings",
10+
],
811
env = {
912
"BZLMOD_ENABLED": "1" if BZLMOD_ENABLED else "0",
1013
},

tests/runfiles/runfiles_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import json
1516
import os
17+
import pathlib
1618
import tempfile
1719
import unittest
1820
from typing import Any, List, Optional
@@ -63,6 +65,14 @@ def testRlocationArgumentValidation(self) -> None:
6365
lambda: r.Rlocation("\\foo"),
6466
)
6567

68+
def testRlocationWithData(self) -> None:
69+
rf = runfiles.Create()
70+
settings_path = rf.Rlocation(
71+
"rules_python/tests/support/current_build_settings.json"
72+
)
73+
settings = json.loads(pathlib.Path(settings_path).read_text())
74+
self.assertIn("bootstrap_impl", settings)
75+
6676
def testCreatesManifestBasedRunfiles(self) -> None:
6777
with _MockFile(contents=["a/b c/d"]) as mf:
6878
r = runfiles.Create(

0 commit comments

Comments
 (0)