forked from extendr/extendr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xtask
add more features (extendr#719)
* fix: extendrtests points to libR-sys submodule updated `xtask` as well * xtask: added `extendrtests` to the `check-fmt`. Added a `cargo extendr fmt` that formats `extendr`-crates and `extendrtests`. * xtask: use `DocumentMut` instead of `Document` from toml_edit * xtask: add `--snapshot-accept` / `-a` option to subcommand `cargo extendr devtools-test` that helps accept newly formed macro-snapshots. * xtask: just pin `toml_edit` to a minor version, instead of an arbitrary patch-version. * xtask: added support for vendored / submodule libR-sys / rextendr, or installed ones. Co-authored-by: Ilia Kosenkov <[email protected]> Co-authored-by: Ilia Kosenkov <[email protected]> * xtask: added comment on which `rextendr` is being used * xtask: ` -a, --accept-snapshot Accept newly generated macro-snapshots` --------- Co-authored-by: Ilia Kosenkov <[email protected]>
- Loading branch information
1 parent
dd1b050
commit 0294a00
Showing
13 changed files
with
184 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use clap::Args; | ||
|
||
#[derive(Args, Debug)] | ||
pub(crate) struct DevtoolsTestArg { | ||
#[arg( | ||
long, | ||
short, | ||
default_value = "false", | ||
help = "Accept newly generated macro-snapshots" | ||
)] | ||
pub(crate) accept_snapshot: bool, | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use xshell::{cmd, Error, Shell}; | ||
|
||
pub(crate) fn run(shell: &Shell) -> Result<(), Error> { | ||
// extendr-api, extendr-macros, extendr-engine, xtask | ||
cmd!(shell, "cargo fmt --all").run()?; | ||
// extendrtests | ||
cmd!( | ||
shell, | ||
"cargo fmt --all --manifest-path tests/extendrtests/src/rust/Cargo.toml" | ||
) | ||
.run()?; | ||
|
||
Ok(()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
use xshell::{cmd, Error, Shell}; | ||
|
||
pub(crate) fn run(shell: &Shell) -> Result<(), Error> { | ||
let check_result = cmd!(shell, "cargo fmt -- --check").run(); | ||
if check_result.is_err() { | ||
println!("Please run `cargo fmt --all`"); | ||
let check_extendr = cmd!(shell, "cargo fmt --all -- --check").run(); | ||
|
||
let check_extendrtests = cmd!( | ||
shell, | ||
"cargo fmt --all --manifest-path tests/extendrtests/src/rust/Cargo.toml -- --check" | ||
) | ||
.run(); | ||
|
||
if check_extendr.is_err() || check_extendrtests.is_err() { | ||
println!("Please run `cargo extendr fmt`"); | ||
} else { | ||
println!("Success!"); | ||
} | ||
|
||
check_result | ||
check_extendr | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub(crate) mod cargo_fmt; | ||
pub(crate) mod cargo_fmt_check; | ||
pub(crate) mod cargo_msrv; | ||
pub(crate) mod devtools_test; | ||
pub(crate) mod generate_docs; | ||
pub(crate) mod r_cmd_check; | ||
pub(crate) mod rextendr_document; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//! This invokes `rextendr::document()` within `tests/extendrtests`. | ||
//! | ||
//! It uses the vendored `rextendr` in the repository as the source package. | ||
//! | ||
//! 1. Ensure that `git submodule update --init` was invoked once, as to setup | ||
//! the vendored `rextendr` package. | ||
//! 2. `devtools` must be installed on system. | ||
//! | ||
//! | ||
//! The idea here is to be able to develop `rextendr` alongside `extendr`, | ||
//! as well as ease the development of extendr. | ||
//! | ||
use std::error::Error; | ||
|
||
use crate::extendrtests::with_absolute_path::{swap_extendr_api_path, R_FOLDER_PATH}; | ||
use xshell::{cmd, Shell}; | ||
|
||
pub(crate) fn run(shell: &Shell) -> Result<(), Box<dyn Error>> { | ||
let _document_handle = swap_extendr_api_path(shell)?; | ||
|
||
run_rextendr_document(shell) | ||
} | ||
|
||
fn run_rextendr_document(shell: &Shell) -> Result<(), Box<dyn Error>> { | ||
let _r_path = shell.push_dir(R_FOLDER_PATH); | ||
|
||
let rextendr_submodule = std::path::Path::new(".../../rextendr"); | ||
let rextendr_submodule = matches!(rextendr_submodule.try_exists(), Ok(true)); | ||
if rextendr_submodule { | ||
println!("Loading vendored `{{rextendr}}`"); | ||
cmd!(shell, "Rscript") | ||
.args([ | ||
"-e", | ||
r#"requireNamespace("devtools")"#, | ||
"-e", | ||
r#"devtools::load_all("../../rextendr")"#, | ||
"-e", | ||
r#"rextendr::document()"#, | ||
]) | ||
.run()?; | ||
} else { | ||
// check if rextendr is installed and use that instead | ||
println!("Using installed `{{rextendr}}`"); | ||
cmd!(shell, "Rscript") | ||
.args([ | ||
"-e", | ||
r#"requireNamespace("rextendr")"#, | ||
"-e", | ||
r#"rextendr::document()"#, | ||
]) | ||
.run()?; | ||
} | ||
|
||
Ok(()) | ||
} |
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
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