ad9f8480c8e08b95d6c217ec4a126bd93b7f376a,tests/python/pants_test/backend/jvm/tasks/test_scalastyle.py,ScalastyleTest,test_get_non_synthetic_scala_targets,#ScalastyleTest#,118

Before Change



  def test_get_non_synthetic_scala_targets(self):
    // scala_library - should remain.
    scala_target_address = BuildFileAddress(
      self.add_to_build_file(
        "a/scala/BUILD", "scala_library(name="s", sources=["Source.scala"])"),
      "s")
    self.build_graph.inject_address_closure(scala_target_address)
    scala_target = self.build_graph.get_target(scala_target_address)

    // scala_library but with java sources - should be filtered
    scala_target_java_source_address = BuildFileAddress(
      self.add_to_build_file(
        "a/scala_java/BUILD", "scala_library(name="sj", sources=["Source.java"])"),
      "sj")
    self.build_graph.inject_address_closure(scala_target_java_source_address)
    scala_target_with_java_source = self.build_graph.get_target(
      scala_target_java_source_address)

    // java_library - should be filtered
    java_target_address = BuildFileAddress(
      self.add_to_build_file(
        "a/java/BUILD", "java_library(name="j", sources=["Source.java"])"),
      "j")
    self.build_graph.inject_address_closure(java_target_address)
    java_target = self.build_graph.get_target(java_target_address)

    // synthetic scala_library - should be filtered
    synthetic_scala_target = self.make_target("a/synthetic_scala:ss", ScalaLibrary)

    // Create a custom context so we can manually inject multiple targets of different source types
    // and synthetic vs non-synthetic to test the target filtering logic.
    context = self._create_context(
      target_roots=[
        java_target,
        scala_target,
        scala_target_with_java_source,
        synthetic_scala_target
      ])

    // scala_library would bring in "scala-library defined in BUILD.tools
    // so we have an extra target here.
    self.assertEqual(5, len(context.targets()))

    // Now create the task and run the non_synthetic scala-only filtering.
    task = self._create_scalastyle_task_from_context(context)
    result_targets = task.get_non_synthetic_scala_targets(context.targets())

    // Only the scala target should remain
    self.assertEquals(1, len(result_targets))
    self.assertEqual(scala_target, result_targets[0])

After Change


      self.set_options_for_scope(ScalaPlatform.options_scope, scalac=":scala-compiler")
      yield

  def test_get_non_synthetic_scala_targets(self):
    with self.scala_platform_setup():
      // scala_library - should remain.
      scala_target = self.make_target("a/scala:s", ScalaLibrary, sources=["Source.scala"])

      // scala_library but with java sources - should be filtered
      scala_target_with_java_source = self.make_target("a/scala_java:sj",
                                                       ScalaLibrary,
                                                       sources=["Source.java"])

      // java_library - should be filtered
      java_target = self.make_target("a/java:j", JavaLibrary, sources=["Source.java"])
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 13

Instances


Project Name: pantsbuild/pants
Commit Name: ad9f8480c8e08b95d6c217ec4a126bd93b7f376a
Time: 2015-08-31
Author: john.sirois@gmail.com
File Name: tests/python/pants_test/backend/jvm/tasks/test_scalastyle.py
Class Name: ScalastyleTest
Method Name: test_get_non_synthetic_scala_targets


Project Name: pantsbuild/pants
Commit Name: ad9f8480c8e08b95d6c217ec4a126bd93b7f376a
Time: 2015-08-31
Author: john.sirois@gmail.com
File Name: tests/python/pants_test/backend/jvm/tasks/test_scalastyle.py
Class Name: ScalastyleTest
Method Name: test_get_non_excluded_scala_sources


Project Name: pantsbuild/pants
Commit Name: ad9f8480c8e08b95d6c217ec4a126bd93b7f376a
Time: 2015-08-31
Author: john.sirois@gmail.com
File Name: tests/python/pants_test/backend/jvm/tasks/test_scalastyle.py
Class Name: ScalastyleTest
Method Name: test_get_non_synthetic_scala_targets


Project Name: pantsbuild/pants
Commit Name: ad9f8480c8e08b95d6c217ec4a126bd93b7f376a
Time: 2015-08-31
Author: john.sirois@gmail.com
File Name: tests/python/pants_test/backend/jvm/targets/test_unpacked_jars.py
Class Name: UnpackedJarsTest
Method Name: test_bad_libraries_ref