hadley/devtools — pull request #615 by robertzk (2014-10-09 22:38:45+00:00)
Title: Support directory traversal to find package root when loading and unload...

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

I have added two utility functions, `is.in_package` and `package_root`.

* `is.in_package` determines whether a `character` represents a path (after `normalizePath`) that somewhere
in its file parent chain has a `DESCRIPTION` file.
* `package_root` 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'`).

Since the former must be called to use the latter in `load_all` and `unload`, I have wrapped `package_root` with `memoise`. I do not have a Windows system to test on so this feature has no effect on the existing behavior of `load_all` and `unload` 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.