hadley/devtools — pull request #616 by robertzk (2014-10-10 01:25:12+00:00)
Title: Support directory traversal to find package root

In response [to the following issue](https://github.com/hadley/devtools/issues/614#issuecomment-58573054), I suggest support for referencing packages using `load_all("some/package/R")` or `load_all("some/package/inst/tests")` (and `document`, `test`, etc.) by traversing up the directory structure for the DESCRIPTION file -- not having this can get annoying.

I have modified `check_dir` in `package.R` and added a `package_root` helper function that returns the absolute path of such a parent directory, or `NA_character_` otherwise. For example, `package_root('some/package/inst/tests')` is `'/absolute/path/to/some/package'`).

I do not have a Windows system to test on so this feature has no effect on the existing behavior of `load_all`, `document`, etc. on Windows platforms. Should support be added, the convergence of repeated applications of `dirname` should be determined (on Linux it's `'/'` or `'.'`).

I also offer the use of [testthatsomemore](http://github.com/robertzk/testthatsomemore) for the unit tests: it creates a file structure extemporaneously for the package in a temporary directory. If you disagree with this decision (e.g., maybe `tempfile()` is dysfunctional on read-only platforms), I can make a flat structure like the other sample packages in the `tests` directory.