Only run junit when there are junit_test targets in the graph

Review Request #2291 - Created May 29, 2015 and submitted

Information
Andy Reitz
pants
9da9920...
Reviewers
pants-reviews
chrischen, fkorotkov, ity, jinfeng, jsirois, nhoward_tw, patricklaw, stuhood, zundel

Pants should only execute the junit task when there are junit_tests targets in the graph. I'm interested in getting some feedback on my new unit test -- I'm not sure if it's actually testing that junit doesn't run.

Before:

[drift pants (master)]$ PANTS_DEV=1 ./pants test.pytest examples/tests/python/example_test/hello/greet --test-junit-test=Success#test_good1
...
23:35:46 00:00   [test]
23:35:46 00:00     [run_prep_command]
23:35:46 00:00       [prep_command]
23:35:46 00:00     [test]
23:35:46 00:00     [pytest]
23:35:46 00:00       [run]
                     ============== test session starts ===============
                     platform darwin -- Python 2.7.6 -- py-1.4.28 -- pytest-2.6.4
                     plugins: cov, timeout
                     collected 2 items 

                     examples/tests/python/example_test/hello/greet/greet.py ..

                     ============ 2 passed in 0.01 seconds ============

23:35:47 00:01     [junit]
23:35:47 00:01       [run]
                     WARN] Scrubbing JAVA_TOOL_OPTIONS=-Dfile.encoding=utf8
Auto-detected 8 processors, using -parallel-threads=8
                     Exception in thread "main" java.lang.RuntimeException: Classloading error during test discovery for Success#test_good1
                        at org.pantsbuild.tools.junit.ConsoleRunner.notFoundError(ConsoleRunner.java:509)
                        at org.pantsbuild.tools.junit.ConsoleRunner.parseRequests(ConsoleRunner.java:396)
                        at org.pantsbuild.tools.junit.ConsoleRunner.run(ConsoleRunner.java:273)
                        at org.pantsbuild.tools.junit.ConsoleRunner.main(ConsoleRunner.java:646)
                     Caused by: java.lang.ClassNotFoundException: Success
                        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
                        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
                        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                        at java.lang.Class.forName0(Native Method)
                        at java.lang.Class.forName(Class.java:270)
                        at org.pantsbuild.tools.junit.ConsoleRunner.loadClass(ConsoleRunner.java:442)
                        at org.pantsbuild.tools.junit.ConsoleRunner.parseRequests(ConsoleRunner.java:382)
                        ... 2 more
                     FATAL: Error during test discovery for Success#test_good1: java.lang.ClassNotFoundException: Success

23:35:47 00:01   [complete]
               FAILURE
``

After:
======

[drift pants (master)]$ PANTS_DEV=1 ./pants test.pytest examples/tests/python/example_test/hello/greet --test-junit-test=Success#test_good1
...
23:56:52 00:00 [test]
23:56:52 00:00 [run_prep_command]
23:56:52 00:00 [prep_command]
23:56:52 00:00 [test]
23:56:52 00:00 [pytest]
23:56:52 00:00 [run]
============== test session starts ===============
platform darwin -- Python 2.7.6 -- py-1.4.28 -- pytest-2.6.4
plugins: cov, timeout
collected 2 items

                 examples/tests/python/example_test/hello/greet/greet.py ..

                 ============ 2 passed in 0.02 seconds ============

23:56:53 00:01 [junit]
23:56:53 00:01 [complete]
SUCCESS
```

Issues

  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Andy Reitz
Chris Chen
Andy Reitz
Nick Howard (Twitter)
Andy Reitz
Nick Howard (Twitter)
Andy Reitz
Nick Howard (Twitter)
Andy Reitz
John Sirois
Andy Reitz
John Sirois
Eric Ayers
Andy Reitz
Review request changed

Status: Closed (submitted)

Andy Reitz

Thanks, submitted @ c5e03878142f70b2a990222e054e73351ea61dcf

Loading...