-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test printing the output of installation failures
- Loading branch information
1 parent
b476a9a
commit afe9395
Showing
8 changed files
with
110 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
#include <R.h> | ||
#include <Rinternals.h> | ||
#include <stdlib.h> // for NULL | ||
|
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 @@ | ||
Package: badcompile | ||
Title: What the Package Does (One Line, Title Case) | ||
Version: 0.0.0.9000 | ||
Authors@R: | ||
person("First", "Last", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "YOUR-ORCID-ID")) | ||
Description: What the package does (one paragraph). | ||
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a | ||
license | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1.9000 |
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,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
useDynLib(badcompile, .registration = TRUE) |
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,4 @@ | ||
## usethis namespace: start | ||
#' @useDynLib badcompile, .registration = TRUE | ||
## usethis namespace: end | ||
NULL |
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,3 @@ | ||
*.o | ||
*.so | ||
*.dll |
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,31 @@ | ||
void f1() { | ||
|
||
} | ||
|
||
void f2() { | ||
|
||
} | ||
|
||
void f3() { | ||
|
||
} | ||
|
||
void f4() { | ||
|
||
} | ||
|
||
void f5() { | ||
|
||
} | ||
|
||
void f6() { | ||
|
||
} | ||
|
||
void f7() { | ||
|
||
} | ||
|
||
void f() { | ||
foobar; | ||
} |
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 @@ | ||
#include <R.h> | ||
#include <Rinternals.h> | ||
#include <R_ext/Rdynload.h> | ||
#define r_export attribute_visible extern | ||
|
||
static const R_CallMethodDef CallEntries[] = { | ||
{ NULL, NULL, 0 } | ||
}; | ||
|
||
r_export void R_init_zip(DllInfo *dll) { | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
R_forceSymbols(dll, TRUE); | ||
} |
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,43 @@ | ||
test_that("output is printed on failure", { | ||
skip_on_cran() | ||
|
||
# Full output in interactive sessions | ||
badcompile <- paste0( | ||
"local::", | ||
normalizePath(test_path("fixtures/badcompile")) | ||
) | ||
tmp <- tempfile() | ||
on.exit(unlink(tmp), add = TRUE) | ||
|
||
expect_error( | ||
callr::r(stdout = tmp, stderr = tmp, function(pkg) { | ||
pkgload::load_all() | ||
options(rlib_interactive = TRUE) | ||
pak::pkg_install(pkg) | ||
}, list(pkg = badcompile)) | ||
) | ||
|
||
lines <- readLines(tmp) | ||
expect_true(any(grepl("Failed to build badcompile", lines))) | ||
expect_true(any(grepl("Full installation output", lines))) | ||
expect_true(any(grepl( | ||
"compilation failed for package .*badcompile.*", | ||
lines | ||
))) | ||
|
||
expect_error( | ||
callr::r(stdout = tmp, stderr = tmp, function(pkg) { | ||
pkgload::load_all() | ||
options(rlib_interactive = FALSE) | ||
pak::pkg_install(pkg) | ||
}, list(pkg = badcompile)) | ||
) | ||
|
||
lines <- readLines(tmp) | ||
expect_true(any(grepl("Failed to build badcompile", lines))) | ||
expect_true(any(grepl("Full installation output", lines))) | ||
expect_true(any(grepl( | ||
"compilation failed for package .*badcompile.*", | ||
lines | ||
))) | ||
}) |