Skip to content

Commit

Permalink
Use setup and teardown functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMadge committed Aug 9, 2024
1 parent 28deb56 commit a219e44
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions integration_tests/Rprofile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.First <- function(){
.libPaths("/root/rpackages")
}

local({
r <- getOption("repos")
r["CRAN"] <- "http://localhost:8080/repository/cran-proxy"
Expand Down
17 changes: 14 additions & 3 deletions integration_tests/tests/cran.bats
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
setup() {
mkdir /root/rpackages
}

teardown() {
rm -rf /root/rpackages
}

@test "Install data.table" {
Rscript -e 'install.packages("data.table")'
run Rscript -e 'install.packages("data.table")'
[[ "$output" == *"package ‘data.table’ successfully unpacked and MD5 sums checked"* ]]
}

@test "Install archived version of data.table" {
Rscript -e 'packagename <- "data.table"
run Rscript -e 'packagename <- "data.table"
version <- "1.13.0" # or 1.12.0
packageurl <- paste0(contrib.url(getOption("repos")), "/Archive/", packagename, "/", packagename, "_", version, ".tar.gz")
install.packages(packageurl, repos=NULL, type="source")
'
[[ "$output" == *"package ‘data.table’ successfully unpacked and MD5 sums checked"* ]]
}

@test "Install archived version of data.table using remotes" {
Rscript -e '
run Rscript -e '
install.packages("remotes")
remotes::install_version("data.table", version = "1.13.0")
'
[[ "$output" == *"package ‘data.table’ successfully unpacked and MD5 sums checked"* ]]
}

@test "Install ggplot2" {
Expand Down
14 changes: 10 additions & 4 deletions integration_tests/tests/pypi.bats
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
setup () {
python3 -m venv /root/venv
. /root/venv/bin/activate
}

teardown() {
deactivate
rm -rf /root/venv
}

@test "Install numpy" {
python3 -m venv ./venv
. ./venv/bin/activate
pip install numpy
}

@test "Install mkdocs" {
bats_require_minimum_version 1.5.0
python3 -m venv ./venv
. ./venv/bin/activate
run ! pip install mkdocs
[ "$status" -eq 1 ]
[[ "$output" == *"HTTP error 403"* ]]
Expand Down

0 comments on commit a219e44

Please sign in to comment.