File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,15 @@ package_annotations_file(
3434 ],
3535 ),
3636 "pkg_c" : package_annotation (
37- additive_build_content = """\
37+ # The `join` and `strip` here accounts for potential differences
38+ # in new lines between unix and windows hosts.
39+ additive_build_content = "\n " .join ([line .strip () for line in """\
3840 cc_library(
3941 name = "my_target",
4042 hdrs = glob(["**/*.h"]),
4143 srcs = glob(["**/*.cc"]),
4244)
43- """ ,
45+ """ . splitlines ()]) ,
4446 data = [":my_target" ],
4547 ),
4648 "pkg_d" : package_annotation (
@@ -57,7 +59,10 @@ py_test(
5759 data = [":mock_annotations" ],
5860 env = {"MOCK_ANNOTATIONS" : "$(rootpath :mock_annotations)" },
5961 tags = ["unit" ],
60- deps = [":lib" ],
62+ deps = [
63+ ":lib" ,
64+ "//python/runfiles" ,
65+ ],
6166)
6267
6368py_test (
Original file line number Diff line number Diff line change 66from pathlib import Path
77
88from python .pip_install .extract_wheels .lib .annotation import Annotation , AnnotationsMap
9+ from python .runfiles import runfiles
910
1011
1112class AnnotationsTestCase (unittest .TestCase ):
@@ -16,7 +17,9 @@ def test_annotations_constructor(self) -> None:
1617 annotations_env = os .environ .get ("MOCK_ANNOTATIONS" )
1718 self .assertIsNotNone (annotations_env )
1819
19- annotations_path = Path .cwd () / annotations_env
20+ r = runfiles .Create ()
21+
22+ annotations_path = Path (r .Rlocation ("rules_python/{}" .format (annotations_env )))
2023 self .assertTrue (annotations_path .exists ())
2124
2225 annotations_map = AnnotationsMap (annotations_path )
@@ -59,14 +62,22 @@ def test_annotations_constructor(self) -> None:
5962 collection ["pkg_c" ],
6063 Annotation (
6164 {
62- "additive_build_content" : textwrap .dedent (
63- """\
65+ # The `join` and `strip` here accounts for potential
66+ # differences in new lines between unix and windows
67+ # hosts.
68+ "additive_build_content" : "\n " .join (
69+ [
70+ line .strip ()
71+ for line in textwrap .dedent (
72+ """\
6473 cc_library(
6574 name = "my_target",
6675 hdrs = glob(["**/*.h"]),
6776 srcs = glob(["**/*.cc"]),
6877 )
6978 """
79+ ).splitlines ()
80+ ]
7081 ),
7182 "copy_executables" : {},
7283 "copy_files" : {},
You can’t perform that action at this time.
0 commit comments