@@ -127,7 +127,7 @@ touch {statsfile}
127
127
arguments = [],
128
128
)
129
129
130
- def _expand_location (ctx , flags ):
130
+ def expand_location (ctx , flags ):
131
131
if hasattr (ctx .attr , "data" ):
132
132
data = ctx .attr .data
133
133
else :
@@ -138,7 +138,7 @@ def _join_path(args, sep = ","):
138
138
return sep .join ([f .path for f in args ])
139
139
140
140
# Return the first non-empty arg. If all are empty, return the last.
141
- def _first_non_empty (* args ):
141
+ def first_non_empty (* args ):
142
142
for arg in args :
143
143
if arg :
144
144
return arg
@@ -307,7 +307,7 @@ StatsfileOutput: {statsfile_output}
307
307
308
308
# scalac_jvm_flags passed in on the target override scalac_jvm_flags passed in on the
309
309
# toolchain
310
- final_scalac_jvm_flags = _first_non_empty (
310
+ final_scalac_jvm_flags = first_non_empty (
311
311
scalac_jvm_flags ,
312
312
ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].scalac_jvm_flags
313
313
)
@@ -330,7 +330,7 @@ StatsfileOutput: {statsfile_output}
330
330
# consume the flags on startup.
331
331
arguments = [
332
332
"--jvm_flag=%s" % f
333
- for f in _expand_location (ctx , final_scalac_jvm_flags )
333
+ for f in expand_location (ctx , final_scalac_jvm_flags )
334
334
] + ["@" + argfile .path ],
335
335
)
336
336
@@ -372,7 +372,7 @@ def try_to_compile_java_jar(
372
372
source_jars = all_srcjars .to_list (),
373
373
source_files = java_srcs ,
374
374
output = full_java_jar ,
375
- javac_opts = _expand_location (
375
+ javac_opts = expand_location (
376
376
ctx ,
377
377
ctx .attr .javacopts + ctx .attr .javac_jvm_flags +
378
378
java_common .default_javac_opts (
@@ -1079,126 +1079,6 @@ trap finish EXIT
1079
1079
1080
1080
return out
1081
1081
1082
- def _scala_test_flags (ctx ):
1083
- # output report test duration
1084
- flags = "-oD"
1085
- if ctx .attr .full_stacktraces :
1086
- flags += "F"
1087
- else :
1088
- flags += "S"
1089
- if not ctx .attr .colors :
1090
- flags += "W"
1091
- return flags
1092
-
1093
- def scala_test_impl (ctx ):
1094
- if len (ctx .attr .suites ) != 0 :
1095
- print ("suites attribute is deprecated. All scalatest test suites are run" )
1096
-
1097
- scalac_provider = get_scalac_provider (ctx )
1098
-
1099
- unused_dependency_checker_mode = get_unused_dependency_checker_mode (ctx )
1100
- unused_dependency_checker_ignored_targets = [
1101
- target .label
1102
- for target in scalac_provider .default_classpath +
1103
- ctx .attr .unused_dependency_checker_ignored_targets
1104
- ]
1105
- unused_dependency_checker_is_off = unused_dependency_checker_mode == "off"
1106
-
1107
- scalatest_base_classpath = scalac_provider .default_classpath + [ctx .attr ._scalatest ]
1108
- jars = collect_jars_from_common_ctx (
1109
- ctx ,
1110
- scalatest_base_classpath ,
1111
- extra_runtime_deps = [
1112
- ctx .attr ._scalatest_reporter ,
1113
- ctx .attr ._scalatest_runner ,
1114
- ],
1115
- unused_dependency_checker_is_off = unused_dependency_checker_is_off ,
1116
- )
1117
- (
1118
- cjars ,
1119
- transitive_rjars ,
1120
- transitive_compile_jars ,
1121
- jars_to_labels ,
1122
- ) = (
1123
- jars .compile_jars ,
1124
- jars .transitive_runtime_jars ,
1125
- jars .transitive_compile_jars ,
1126
- jars .jars2labels ,
1127
- )
1128
-
1129
- args = "\n " .join ([
1130
- "-R" ,
1131
- ctx .outputs .jar .short_path ,
1132
- _scala_test_flags (ctx ),
1133
- "-C" ,
1134
- "io.bazel.rules.scala.JUnitXmlReporter" ,
1135
- ])
1136
-
1137
- argsFile = ctx .actions .declare_file ("%s.args" % ctx .label .name )
1138
- ctx .actions .write (argsFile , args )
1139
-
1140
- executable = declare_executable (ctx )
1141
-
1142
- wrapper = write_java_wrapper (ctx , "" , "" )
1143
- out = scala_binary_common (
1144
- ctx ,
1145
- executable ,
1146
- cjars ,
1147
- transitive_rjars ,
1148
- transitive_compile_jars ,
1149
- jars_to_labels ,
1150
- wrapper ,
1151
- unused_dependency_checker_ignored_targets =
1152
- unused_dependency_checker_ignored_targets ,
1153
- unused_dependency_checker_mode = unused_dependency_checker_mode ,
1154
- runfiles_ext = [argsFile ],
1155
- deps_providers = jars .deps_providers ,
1156
- )
1157
-
1158
- rjars = out .transitive_rjars
1159
-
1160
- coverage_runfiles = []
1161
- if ctx .configuration .coverage_enabled and _coverage_replacements_provider .is_enabled (ctx ):
1162
- coverage_replacements = _coverage_replacements_provider .from_ctx (
1163
- ctx ,
1164
- base = out .coverage .replacements ,
1165
- ).replacements
1166
-
1167
- rjars = depset ([
1168
- coverage_replacements [jar ] if jar in coverage_replacements else jar
1169
- for jar in rjars .to_list ()
1170
- ])
1171
- coverage_runfiles = ctx .files ._jacocorunner + ctx .files ._lcov_merger + coverage_replacements .values ()
1172
-
1173
- # jvm_flags passed in on the target override scala_test_jvm_flags passed in on the
1174
- # toolchain
1175
- final_jvm_flags = _first_non_empty (
1176
- ctx .attr .jvm_flags ,
1177
- ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].scala_test_jvm_flags
1178
- )
1179
-
1180
- coverage_runfiles .extend (write_executable (
1181
- ctx = ctx ,
1182
- executable = executable ,
1183
- jvm_flags = [
1184
- "-DRULES_SCALA_MAIN_WS_NAME=%s" % ctx .workspace_name ,
1185
- "-DRULES_SCALA_ARGS_FILE=%s" % argsFile .short_path ,
1186
- ] + _expand_location (ctx , final_jvm_flags ),
1187
- main_class = ctx .attr .main_class ,
1188
- rjars = rjars ,
1189
- use_jacoco = ctx .configuration .coverage_enabled ,
1190
- wrapper = wrapper ,
1191
- ))
1192
-
1193
- return struct (
1194
- executable = executable ,
1195
- files = out .files ,
1196
- instrumented_files = out .instrumented_files ,
1197
- providers = out .providers ,
1198
- runfiles = ctx .runfiles (coverage_runfiles , transitive_files = out .runfiles .files ),
1199
- scala = out .scala ,
1200
- )
1201
-
1202
1082
def _gen_test_suite_flags_based_on_prefixes_and_suffixes (ctx , archives ):
1203
1083
return struct (
1204
1084
archiveFlag = "-Dbazel.discover.classes.archives.file.paths=%s" %
0 commit comments