Ensure that the default timeout in .buckconfig works with @RunWith.

Summary:
The custom logic that we use to support a default timeout for tests in `.buckconfig`
relies on our ability to use a `BuckBlockJUnit4ClassRunner` in place of a
`BlockJUnit4ClassRunner` when running JUnit. Unfortunately, when `@RunWith`
is present, the code path to produce a `BlockJUnit4ClassRunner` is not exercised,
which means our `BuckBlockJUnit4ClassRunner` is not inserted, which means
that our default timeout is not enforced.

This diff modifies the `AllDefaultPossibilitiesBuilder` that is used to select the factory
that is used to produce a `Runner` (which may or may not be a `BlockJUnit4ClassRunner`).
When `@RunWith` is present, we now take the `Runner` that is produced as a result of the
`@RunWith` annotation and wrap it with a `DelegateRunnerWithTimeout` that enforces our
default timeout.

It does this by taking the `RunNotifier` passed by the client and wrapping it in a
`DelegateRunNotifier`, which is passed to the original `Runner`. Our `DelegateRunNotifier`
intercepts events from the original `Runner` and passes them on based on the state of
test execution relative to the default timeout from `.buckconfig`.

Unfortunately, the logic in our `DelegateRunnerWithTimeout`/`DelegateRunNotifier` is not
as airtight as the logic in our `BuckBlockJUnit4ClassRunner`, so we are not going to delete
our `BuckBlockJUnit4ClassRunner` codepath just yet.

Test Plan: RunWithDefaultTimeoutIntegrationTest.
15 files changed
tree: 5c820604a9a73a1acb3a620ac9b14c6d7b0ee0e3
  1. .buckconfig
  2. .classpath
  3. .gitignore
  4. .idea/
  5. .project
  6. DEFS
  7. LICENSE
  8. README.md
  9. bin/
  10. buck.iml
  11. build.xml
  12. config/
  13. docs/
  14. lib/
  15. plugin/
  16. pmd/
  17. scripts/
  18. src/
  19. test/
  20. testdata/
  21. third-party/
README.md

Buck

Buck is an Android build tool. To see what Buck can do for you, check out the documentation at http://facebook.github.io/buck/.

Installation

To build Buck, run the following:

git clone git@github.com:facebook/buck.git
cd buck
ant
./bin/buck --help

License

Apache License 2.0