@@ -136,6 +136,10 @@ filegroup(
136136
137137CURRENT_VERSION = "current"
138138
139+ # BazelTestSettings holds information about the test environment, gathered by
140+ # the bazel_test_settings rule.
141+ BazelTestSettings = provider ()
142+
139143def _bazel_test_script_impl (ctx ):
140144 base_label = ctx .label
141145 if not base_label .workspace_root :
@@ -176,7 +180,7 @@ def _bazel_test_script_impl(ctx):
176180 workspace_content += 'local_repository(name="{name}", path="{exec_root}/{root}")\n ' .format (
177181 name = name ,
178182 root = root ,
179- exec_root = ctx .attr ._settings .exec_root ,
183+ exec_root = ctx .attr ._settings [ BazelTestSettings ] .exec_root ,
180184 )
181185 if ctx .attr .workspace :
182186 workspace_content += ctx .attr .workspace
@@ -199,9 +203,9 @@ def _bazel_test_script_impl(ctx):
199203 logs = [_testlog_path (t ) for t in targets ]
200204
201205 script_content = _bazel_test_script_template .format (
202- bazelrc = shell .quote (ctx .attr ._settings .exec_root + "/" + ctx .file .bazelrc .path ),
206+ bazelrc = shell .quote (ctx .attr ._settings [ BazelTestSettings ] .exec_root + "/" + ctx .file .bazelrc .path ),
203207 config = ctx .attr .config ,
204- extra_files = " " .join ([shell .quote (paths .join (ctx .attr ._settings .exec_root , "execroot" , "io_bazel_rules_go" , file .path )) for file in ctx .files .extra_files ]),
208+ extra_files = " " .join ([shell .quote (paths .join (ctx .attr ._settings [ BazelTestSettings ] .exec_root , "execroot" , "io_bazel_rules_go" , file .path )) for file in ctx .files .extra_files ]),
205209 command = ctx .attr .command ,
206210 args = " " .join (ctx .attr .args ),
207211 target = " " .join ([str (t ) for t in targets ]),
@@ -210,9 +214,9 @@ def _bazel_test_script_impl(ctx):
210214 workspace = shell .quote (workspace_file .short_path ),
211215 build = shell .quote (build_file .short_path ),
212216 output = shell .quote (output ),
213- bazel = ctx .attr ._settings .bazel ,
214- work_dir = shell .quote (ctx .attr ._settings .scratch_dir + "/" + ctx .attr .config ),
215- cache_dir = shell .quote (ctx .attr ._settings .scratch_dir + "/cache" ),
217+ bazel = ctx .attr ._settings [ BazelTestSettings ] .bazel ,
218+ work_dir = shell .quote (ctx .attr ._settings [ BazelTestSettings ] .scratch_dir + "/" + ctx .attr .config ),
219+ cache_dir = shell .quote (ctx .attr ._settings [ BazelTestSettings ] .scratch_dir + "/cache" ),
216220 clean_build = "1" if ctx .attr .clean_build else "0" ,
217221 )
218222 ctx .actions .write (output = script_file , is_executable = True , content = script_content )
@@ -367,11 +371,11 @@ _test_environment = repository_rule(
367371)
368372
369373def _bazel_test_settings_impl (ctx ):
370- return struct (
374+ return [ BazelTestSettings (
371375 bazel = ctx .attr .bazel ,
372376 exec_root = ctx .attr .exec_root ,
373377 scratch_dir = ctx .attr .scratch_dir ,
374- )
378+ )]
375379
376380bazel_test_settings = rule (
377381 _bazel_test_settings_impl ,
0 commit comments