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. .idea/
  2. bin/
  3. config/
  4. docs/
  5. lib/
  6. plugin/
  7. pmd/
  8. scripts/
  9. src/
  10. test/
  11. testdata/
  12. third-party/
  13. .buckconfig
  14. .classpath
  15. .gitignore
  16. .project
  17. buck.iml
  18. build.xml
  19. DEFS
  20. LICENSE
  21. README.md
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