File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,15 @@ package_annotations_file(
34
34
],
35
35
),
36
36
"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 """\
38
40
cc_library(
39
41
name = "my_target",
40
42
hdrs = glob(["**/*.h"]),
41
43
srcs = glob(["**/*.cc"]),
42
44
)
43
- """ ,
45
+ """ . splitlines ()]) ,
44
46
data = [":my_target" ],
45
47
),
46
48
"pkg_d" : package_annotation (
@@ -57,7 +59,10 @@ py_test(
57
59
data = [":mock_annotations" ],
58
60
env = {"MOCK_ANNOTATIONS" : "$(rootpath :mock_annotations)" },
59
61
tags = ["unit" ],
60
- deps = [":lib" ],
62
+ deps = [
63
+ ":lib" ,
64
+ "//python/runfiles" ,
65
+ ],
61
66
)
62
67
63
68
py_test (
Original file line number Diff line number Diff line change 6
6
from pathlib import Path
7
7
8
8
from python .pip_install .extract_wheels .lib .annotation import Annotation , AnnotationsMap
9
+ from python .runfiles import runfiles
9
10
10
11
11
12
class AnnotationsTestCase (unittest .TestCase ):
@@ -16,7 +17,9 @@ def test_annotations_constructor(self) -> None:
16
17
annotations_env = os .environ .get ("MOCK_ANNOTATIONS" )
17
18
self .assertIsNotNone (annotations_env )
18
19
19
- annotations_path = Path .cwd () / annotations_env
20
+ r = runfiles .Create ()
21
+
22
+ annotations_path = Path (r .Rlocation ("rules_python/{}" .format (annotations_env )))
20
23
self .assertTrue (annotations_path .exists ())
21
24
22
25
annotations_map = AnnotationsMap (annotations_path )
@@ -59,14 +62,22 @@ def test_annotations_constructor(self) -> None:
59
62
collection ["pkg_c" ],
60
63
Annotation (
61
64
{
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
+ """\
64
73
cc_library(
65
74
name = "my_target",
66
75
hdrs = glob(["**/*.h"]),
67
76
srcs = glob(["**/*.cc"]),
68
77
)
69
78
"""
79
+ ).splitlines ()
80
+ ]
70
81
),
71
82
"copy_executables" : {},
72
83
"copy_files" : {},
You can’t perform that action at this time.
0 commit comments