Skip to content

Instantly share code, notes, and snippets.

@JosiahParry
Created September 6, 2024 20:08
Show Gist options
  • Save JosiahParry/94d5b72430c688ff742b7652e78c1343 to your computer and use it in GitHub Desktop.
Save JosiahParry/94d5b72430c688ff742b7652e78c1343 to your computer and use it in GitHub Desktop.
testthat-cli R
[package]
name = "testthat-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
argh = "0.1.12"
use argh::FromArgs;
use std::process::Command;
#[derive(Clone, Debug, FromArgs)]
/// Test an R package using testthat
struct TestThatDir {
/// path to a package's directory
#[argh(positional, default = r#"String::from(".")"#)]
dir: String,
}
fn main() {
let ttd: TestThatDir = argh::from_env();
let devtools_call = format!("devtools::test('{}')", ttd.dir);
let _ = Command::new("R")
.args(["--quiet", "-e", &devtools_call])
.spawn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment