How can I control the arguments of devtools function arguments called by RStudio?

My motivating example is wanting to skip test files using the filter argument of devtools::test(). Currently if I use Build > Test Package in RStudio (or the equivalent shortcut) the test output shows conveniently in the Build pane. However, I cannot configure the arguments passed to test(). I think the same issue arises for load_all(), document(), check() and other devtools build functions with RStudio integration.

Of course I can run the function with my preferred filters in the console as a workaround, but I'd like to know if I can avoid the workaround.

1 Like

With RStudio you can customize the build options. Unfortunately not all are as easy to configure.

For example, the most granular options are provided for document(). You can choose which files roxygen should process, and when the roxygen process should be invoked.

For Install, Build, and Check shortcuts, I don't think you can specify arguments to the devtools functions. Instead, you can provide flags to the equivalent R CMD commands.

For testing, I don't see any way to pass arguments like filter. Recent versions of RStudio have a button in the Editor pane to "Run Tests". This does what you want, i.e. tests a single file and shows the results in the Build pane. By default it is not tied to a keyboard shortcut, but you could make it a shortcut yourself (Tools->Modify keyboard shortcuts...).

For ultimate control, you can switch your build tool from Package to Makefile or Custom. Then you could write your own commands. However, I don't think it would be easy to dynamically pass arguments to them. In other words, you would have to manually set the argument filter in your build script.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.