Skip to content

Commit

Permalink
Add scala tests to CI
Browse files Browse the repository at this point in the history
--
Change-Id: If286a9718e036d2bd555baf78600e9208ba5a990
Reviewed-on: bazelbuild#872
MOS_MIGRATED_REVID=114563576
  • Loading branch information
johnynek authored and damienmg committed Feb 15, 2016
1 parent accfc2c commit b5d417d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ if [ $DO_TESTS ]; then
${EXTRA_BAZEL_ARGS} \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
-k --test_output=errors //src/... //third_party/ijar/... //scripts/... \
//tools/build_defs/scala/test/... \
|| fail "Tests failed"
fi

Expand Down
38 changes: 23 additions & 15 deletions tools/build_defs/scala/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -118,32 +118,40 @@ cd $0.runfiles
content=content)

def _collect_comp_run_jars(ctx):
compile_jars = set()
runtime_jars = set()
compile_jars = set() # not transitive
runtime_jars = set() # this is transitive
for target in ctx.attr.deps:
if hasattr(target, "runtime_jar_files"):
runtime_jars += target.runtime_jar_files
if hasattr(target, "interface_jar_files"):
compile_jars += target.interface_jar_files
found = False
if hasattr(target, "scala"):
compile_jars += [target.scala.outputs.ijar]
runtime_jars += target.scala.transitive_runtime_deps
found = True
if hasattr(target, "java"):
runtime_jars += target.java.transitive_runtime_deps
#see JavaSkylarkApiProvider.java, this is just the compile-time deps
# see JavaSkylarkApiProvider.java, this is just the compile-time deps
# this should be improved in bazel 0.1.5 to get outputs.ijar
# compile_jars += [target.java.outputs.ijar]
compile_jars += target.java.transitive_deps
runtime_jars += target.java.transitive_runtime_deps
found = True
if not found:
# support http_file pointed at a jar. http_jar uses ijar, which breaks scala macros
runtime_jars += target.files
compile_jars += target.files
return (compile_jars, runtime_jars)

def _scala_library_impl(ctx):
(cjars, rjars) = _collect_comp_run_jars(ctx)
_write_manifest(ctx)
_compile(ctx, cjars, True)

cjars += [ctx.outputs.ijar]
rjars += [ctx.outputs.jar]
scalaattr = struct(outputs = struct(ijar=ctx.outputs.ijar, class_jar=ctx.outputs.jar),
transitive_runtime_deps = rjars)
runfiles = ctx.runfiles(
files = list(rjars),
collect_data = True)
return struct(
runtime_jar_files=rjars,
interface_jar_files=cjars,
scala = scalaattr,
runfiles=runfiles)

def _scala_macro_library_impl(ctx):
Expand All @@ -152,14 +160,14 @@ def _scala_macro_library_impl(ctx):
_compile(ctx, cjars, False)

rjars += [ctx.outputs.jar]
# macro code needs to be available at compiletime
cjars += [ctx.outputs.jar]
# macro code needs to be available at compiletime, so set ijar == jar
scalaattr = struct(outputs = struct(ijar=ctx.outputs.jar, class_jar=ctx.outputs.jar),
transitive_runtime_deps = rjars)
runfiles = ctx.runfiles(
files = list(rjars),
collect_data = True)
return struct(
runtime_jar_files=rjars,
interface_jar_files=cjars,
scala = scalaattr,
runfiles=runfiles)

# Common code shared by all scala binary implementations.
Expand Down
2 changes: 1 addition & 1 deletion tools/build_defs/scala/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ scala_library(

scala_test(
name = "HelloLibTest",
size = "medium", # Not a macro, can pass test-specific attributes.
size = "small", # Not a macro, can pass test-specific attributes.
srcs = ["HelloLibTest.scala"],
suites = [
"scala.test.ScalaSuite",
Expand Down

0 comments on commit b5d417d

Please sign in to comment.