ad9f8480c8e08b95d6c217ec4a126bd93b7f376a,tests/python/pants_test/backend/jvm/tasks/test_scalastyle.py,ScalastyleTest,test_get_non_excluded_scala_sources,#ScalastyleTest#,169

Before Change


  def test_get_non_excluded_scala_sources(self):
    // this scala target has mixed *.scala and *.java sources.
    // the *.java source should be filtered out.
    scala_target_address_1 = BuildFileAddress(
      self.add_to_build_file(
        "a/scala_1/BUILD",
        "scala_library(name="s1", sources=["Source1.java", "Source1.scala"])"),
      "s1")
    self.build_graph.inject_address_closure(scala_target_address_1)
    scala_target_1 = self.build_graph.get_target(scala_target_address_1)

    // this scala target has single *.scala source but will be excluded out
    // by the [scalastyle].[excludes] setting.
    scala_target_address_2 = BuildFileAddress(
      self.add_to_build_file(
        "a/scala_2/BUILD", "scala_library(name="s2", sources=["Source2.scala"])"),
      "s2")
    self.build_graph.inject_address_closure(scala_target_address_2)
    scala_target_2 = self.build_graph.get_target(scala_target_address_2)

    // Create a custom context so we can manually inject scala targets
    // with mixed sources in them to test the source filtering logic.
    context = self._create_context(
      scalastyle_config=self._create_scalastyle_config_file(),
      excludes=self._create_scalastyle_excludes_file(["a/scala_2/Source2.scala"]),
      target_roots=[
        scala_target_1,
        scala_target_2
      ]
    )

    // Remember, we have the extra "scala-library-2.9.3" dep target.
    self.assertEqual(3, len(context.targets()))

After Change


      self.assertEqual(scala_target, result_targets[0])

  def test_get_non_excluded_scala_sources(self):
    with self.scala_platform_setup():
      // this scala target has mixed *.scala and *.java sources.
      // the *.java source should be filtered out.
      scala_target_1 = self.make_target("a/scala_1:s1",
                                        ScalaLibrary,
                                        sources=["Source1.java", "Source1.scala"])

      // this scala target has single *.scala source but will be excluded out
      // by the [scalastyle].[excludes] setting.
      scala_target_2 = self.make_target("a/scala_2:s2", ScalaLibrary, sources=["Source2.scala"])

      // Create a custom context so we can manually inject scala targets
      // with mixed sources in them to test the source filtering logic.
      context = self._create_context(
        scalastyle_config=self._create_scalastyle_config_file(),
        excludes=self._create_scalastyle_excludes_file(["a/scala_2/Source2.scala"]),
        target_roots=[
          scala_target_1,
          scala_target_2
        ]
      )

      // Remember, we have the extra "scala-library" dep target.
      self.assertEqual(3, len(context.targets()))

      // Now create the task and run the scala source and exclusion filtering.
      task = self.prepare_execute(context)

      result_sources = task.get_non_excluded_scala_sources(
        task.create_file_excluder(),
        task.get_non_synthetic_scala_targets(context.targets()))

      // Only the scala source from target 1 should remain
      self.assertEquals(1, len(result_sources))
      self.assertEqual("a/scala_1/Source1.scala", result_sources[0])

  @ensure_cached(Scalastyle, expected_num_artifacts=1)
  def test_end_to_end_pass(self):
    // Default scalastyle config (import grouping rule) and no excludes.
    with self.scala_platform_setup():
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 15

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_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/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_end_to_end_pass


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_fail