Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Attempt to use an External Dependency #2

Closed
wants to merge 2 commits into from

Conversation

promiseofcake
Copy link
Owner

@promiseofcake promiseofcake commented Oct 17, 2017

We currently have a working build for scala_library and scala_test targets. This PR will illustrate how the new SimpleParser main class external dependencies are not used for scala_test targets.

cef927d:

  • Import org_scala_lang_scala_parser_combinators
  • Add a SimpleParser example for scala.util.parsing.combinator._

6b27703:

  • Add the external dependency to the scala_test target and see it succeed.

@promiseofcake promiseofcake force-pushed the ljk/test-external-deps branch from 960a45f to cef927d Compare October 23, 2017 20:09
@promiseofcake
Copy link
Owner Author

When running on cef927d:

$ bazel build //src/main/scala/Sample:simple_parser 
INFO: Analysed target //src/main/scala/Sample:simple_parser.
INFO: Found 1 target...
Target //src/main/scala/Sample:simple_parser up-to-date:
  bazel-bin/src/main/scala/Sample/simple_parser.jar
INFO: Elapsed time: 0.286s, Critical Path: 0.00s
INFO: Build completed successfully, 1 total action
$ bazel test //src/test/scala/Sample:simple_parser_test 
INFO: Analysed target //src/test/scala/Sample:simple_parser_test.
INFO: Found 1 test target...
ERROR: /Users/lucas/Workspace/repos/promiseofcake/scala-test/src/test/scala/Sample/BUILD:14:1: scala //src/test/scala/Sample:simple_parser_test failed (Exit 1): scalac failed: error executing command 
  (cd /private/var/tmp/_bazel_lucas/38ce124245a89f3c8f10f0656b79414e/execroot/__main__ && \
  exec env - \
  bazel-out/host/bin/external/io_bazel_rules_scala/src/java/io/bazel/rulesscala/scalac/scalac @bazel-out/darwin_x86_64-fastbuild/bin/src/test/scala/Sample/simple_parser_test_worker_input)
src/test/scala/Sample/SimpleParserTest.scala:7: error: Symbol 'term scala.util.parsing' is missing from the classpath.
This symbol is required by 'object Sample.SimpleParser'.
Make sure that term parsing is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'SimpleParser.class' was compiled against an incompatible version of scala.util.
(NOTE: It looks like the scala-parser-combinators module is missing; try adding a dependency on "org.scala-lang.modules" : "scala-parser-combinators".
       See http://docs.scala-lang.org/overviews/ for more information.)
    SimpleParser.parse(SimpleParser.word, "johnny come lately")
    ^
src/test/scala/Sample/SimpleParserTest.scala:7: error: value parse is not a member of object Sample.SimpleParser
    SimpleParser.parse(SimpleParser.word, "johnny come lately")
                 ^
two errors found
two errors found
java.lang.RuntimeException: Build failed
        at io.bazel.rulesscala.scalac.ScalacProcessor.compileScalaSources(ScalacProcessor.java:256)
        at io.bazel.rulesscala.scalac.ScalacProcessor.processRequest(ScalacProcessor.java:68)
        at io.bazel.rulesscala.worker.GenericWorker.run(GenericWorker.java:125)
        at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:41)
Target //src/test/scala/Sample:simple_parser_test failed to build
INFO: Elapsed time: 1.817s, Critical Path: 1.72s
FAILED: Build did NOT complete successfully

Executed 0 out of 1 test: 1 fails to build.

@promiseofcake
Copy link
Owner Author

When running on 6b27703:

Which adds org_scala_lang_scala_parser_combinators to the test deps.

scala_test(
    name = "simple_parser_test",
    size = "small",
    srcs = ["SimpleParserTest.scala"],
    deps = [
        "//src/main/scala/Sample:simple_parser",
        "@org_scala_lang_scala_parser_combinators//jar"
    ],
)
$ bazel build //src/main/scala/Sample:simple_parser 
INFO: Analysed target //src/main/scala/Sample:simple_parser.
INFO: Found 1 target...
Target //src/main/scala/Sample:simple_parser up-to-date:
  bazel-bin/src/main/scala/Sample/simple_parser.jar
INFO: Elapsed time: 0.090s, Critical Path: 0.00s
INFO: Build completed successfully, 1 total action
$ bazel test //src/test/scala/Sample:simple_parser_test 
INFO: Analysed target //src/test/scala/Sample:simple_parser_test.
INFO: Found 1 test target...
Target //src/test/scala/Sample:simple_parser_test up-to-date:
  bazel-bin/src/test/scala/Sample/simple_parser_test
INFO: Elapsed time: 2.693s, Critical Path: 2.59s
INFO: Build completed successfully, 3 total actions

Executed 1 out of 1 test: 1 test passes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant