Skip to content

Commit

Permalink
fix(R microkernel): Suppress warnings when requiring
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Dec 7, 2021
1 parent bee1710 commit d847313
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/kernel-r/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ kernel-micro = { path = "../kernel-micro", version = "0.0.0" }
[dev-dependencies]
tokio = { version = "1.13.0", features = ["macros"] }
test-utils = { path = "../test-utils", version = "0.0.0" }
serial_test = "0.5.1"
13 changes: 11 additions & 2 deletions rust/kernel-r/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod tests {
stencila_schema::Node,
KernelTrait,
};
use serial_test::serial;
use test_utils::{assert_json_eq, print_logs, serde_json::json};

async fn skip_or_kernel() -> Result<MicroKernel> {
Expand All @@ -37,11 +38,17 @@ mod tests {
Ok(kernel)
}

// Run these tests serially to avoid parallel installation of dependencies
// which may interfere with each other.

/// Tests of basic functionality
/// This test is replicated in all the microkernels.
/// Other test should be written for language specific quirks and regressions.
#[tokio::test]
#[serial]
async fn basics() -> Result<()> {
print_logs();

let mut kernel = match skip_or_kernel().await {
Ok(kernel) => kernel,
Err(..) => return Ok(()),
Expand Down Expand Up @@ -87,6 +94,7 @@ mod tests {

/// Test that an assignment on the last line does not generate an output
#[tokio::test]
#[serial]
async fn assignment_no_output() -> Result<()> {
let mut kernel = match skip_or_kernel().await {
Ok(kernel) => kernel,
Expand All @@ -109,6 +117,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn encode_general() -> Result<()> {
let mut kernel = match skip_or_kernel().await {
Ok(kernel) => kernel,
Expand Down Expand Up @@ -146,6 +155,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn encode_dataframes() -> Result<()> {
let mut kernel = match skip_or_kernel().await {
Ok(kernel) => kernel,
Expand Down Expand Up @@ -249,14 +259,13 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn encode_plots() -> Result<()> {
let mut kernel = match skip_or_kernel().await {
Ok(kernel) => kernel,
Err(..) => return Ok(()),
};

print_logs();

for code in ["plot(1)", "hist(rnorm(1000), breaks=30)"] {
let (outputs, messages) = kernel.exec(code).await?;
assert_json_eq!(messages, json!([]));
Expand Down
2 changes: 1 addition & 1 deletion rust/kernel-r/src/r-codec.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install necessary packages (if not already)
for (pkg in c("jsonlite", "base64enc")) {
if (!suppressMessages(require(pkg, character.only = TRUE, quietly=TRUE))) {
if (!suppressWarnings(require(pkg, character.only = TRUE, quietly=TRUE))) {
suppressMessages(install.packages(pkg, quiet = TRUE, repo="http://cran.rstudio.com/"))
suppressMessages(require(pkg, character.only = TRUE, quietly=TRUE))
}
Expand Down

0 comments on commit d847313

Please sign in to comment.