commit f46e0702f4409d982b79cab9a3789b35090d46a4 Author: John Sirois Date: Mon Sep 26 20:01:03 2016 -0600 Fix handling of method specs. Previously the method spec handling code did not guard against non-test classes and would throw an NPE. This change adds a failing test and fixes the handling to deal with `Optional`. The `Spec` class is made immutable in the process to improve the code's ability to be reasoned about. Testing Done: I noticed this issue when attempting the following: ``` ./pants test.junit \ --no-timeouts \ --open \ --coverage-open \ --test=tests/java/org/pantsbuild/args4j/ParserTest.java#test{Failure,Success} \ tests/java/org/pantsbuild/args4j/:: ... 11:26:39 00:03 [run] OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 OpenJDK 64-Bit Server VM warning: ignoring option UseSplitVerifier; support was removed in 8.0 Auto-detected 8 processors, using -parallel-threads=8 Exception in thread "main" java.lang.NullPointerException at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.SpecParser.addMethod(SpecParser.java:130) at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.SpecParser.parse(SpecParser.java:61) at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConsoleRunnerImpl.run(ConsoleRunnerImpl.java:455) at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConsoleRunnerImpl.main(ConsoleRunnerImpl.java:845) at org.pantsbuild.tools.junit.ConsoleRunner.main(ConsoleRunner.java:12) Test failed: java org.pantsbuild.tools.junit.ConsoleRunner ... exited non-zero (1); 0 failed 0 targets. ... ``` Locally green using `./pants test-changed`. CI went green here: https://travis-ci.org/pantsbuild/pants/builds/162902557 Bugs closed: 3902 Reviewed at https://rbcommons.com/s/twitter/r/4258/ .../tools/junit/impl/ConsoleRunnerImpl.java | 15 ++-- src/java/org/pantsbuild/tools/junit/impl/Spec.java | 40 ++++++---- .../pantsbuild/tools/junit/impl/SpecException.java | 8 +- .../pantsbuild/tools/junit/impl/SpecParser.java | 90 +++++++++------------- 4 files changed, 70 insertions(+), 83 deletions(-)