Created
September 6, 2024 20:08
-
-
Save JosiahParry/94d5b72430c688ff742b7652e78c1343 to your computer and use it in GitHub Desktop.
testthat-cli R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "testthat-cli" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
argh = "0.1.12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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