-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat create_renv_for_dev can work even outside of an R packages
- Loading branch information
1 parent
78f97a7
commit 2df6318
Showing
5 changed files
with
135 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
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,2 @@ | ||
library(dplyr) | ||
library(sudoku) |
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,28 @@ | ||
# | ||
# This is the server logic of a Shiny web application. You can run the | ||
# application by clicking 'Run App' above. | ||
# | ||
# Find out more about building applications with Shiny here: | ||
# | ||
# http://shiny.rstudio.com/ | ||
# | ||
|
||
library(shiny) | ||
|
||
# Define server logic required to draw a histogram | ||
function(input, output, session) { | ||
|
||
output$distPlot <- renderPlot({ | ||
|
||
# generate bins based on input$bins from ui.R | ||
x <- faithful[, 2] | ||
bins <- seq(min(x), max(x), length.out = input$bins + 1) | ||
|
||
# draw the histogram with the specified number of bins | ||
hist(x, breaks = bins, col = 'darkgray', border = 'white', | ||
xlab = 'Waiting time to next eruption (in mins)', | ||
main = 'Histogram of waiting times') | ||
|
||
}) | ||
|
||
} |
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,33 @@ | ||
# | ||
# This is the user-interface definition of a Shiny web application. You can | ||
# run the application by clicking 'Run App' above. | ||
# | ||
# Find out more about building applications with Shiny here: | ||
# | ||
# http://shiny.rstudio.com/ | ||
# | ||
|
||
library(shiny) | ||
|
||
# Define UI for application that draws a histogram | ||
fluidPage( | ||
|
||
# Application title | ||
titlePanel("Old Faithful Geyser Data"), | ||
|
||
# Sidebar with a slider input for number of bins | ||
sidebarLayout( | ||
sidebarPanel( | ||
sliderInput("bins", | ||
"Number of bins:", | ||
min = 1, | ||
max = 50, | ||
value = 30) | ||
), | ||
|
||
# Show a plot of the generated distribution | ||
mainPanel( | ||
plotOutput("distPlot") | ||
) | ||
) | ||
) |
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,49 @@ | ||
# These tests can not run on CRAN | ||
skip_on_cran() | ||
|
||
if (length(find.package("extrapackage", quiet = TRUE)) != 0) { | ||
unlink(find.package("extrapackage", quiet = TRUE), recursive = TRUE) | ||
} | ||
|
||
# test on dummy package | ||
tmpdir <- tempfile(pattern = "pkgrenv2") | ||
dir.create(tmpdir) | ||
file.copy( | ||
system.file("dummyfolder", package = "attachment"), tmpdir, | ||
recursive = TRUE | ||
) | ||
dummyfolder <- file.path(tmpdir, "dummyfolder") | ||
lock_ <- file.path(tmpdir, "my_lock.lock") | ||
|
||
|
||
expect_message({ | ||
|
||
my_renv_ <- create_renv_for_dev( | ||
path = dummyfolder, | ||
install_if_missing = FALSE, | ||
output = lock_, | ||
# force generation of a lockfile even when pre-flight validation checks have failed? | ||
force = TRUE)} | ||
) | ||
|
||
|
||
|
||
|
||
|
||
test_that("create_renv_for_dev creates lock files even without DESCRIPTION file", { | ||
expect_true(file.exists(lock_)) | ||
}) | ||
|
||
# print(my_renv_extra) | ||
|
||
|
||
renv_content <- getFromNamespace("lockfile", "renv")(my_renv_) | ||
|
||
|
||
test_that("lockfile are correct renv files", { | ||
expect_s3_class(renv_content, "renv_lockfile_api") | ||
expect_true("dplyr" %in% names(renv_content$data()$Packages)) | ||
expect_true("sudoku" %in% names(renv_content$data()$Packages)) | ||
}) | ||
|
||
|