diff --git a/.Rbuildignore b/.Rbuildignore index 144e1b7..72bc654 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -26,3 +26,4 @@ cmake-build-debug$ ^codecov\.yml$ ^_pkgdown\.yml$ ^docs$ +^docker$ diff --git a/.gitignore b/.gitignore index 596c1d5..f6e5a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ /CMakeLists.txt /clion-test.R /cmake-build-debug/ +*~ diff --git a/.travis.yml b/.travis.yml index 04e98a1..c744921 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,25 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r +os: linux +services: docker + +before_install: + - make docker-pull + - make info -language: R -sudo: false -cache: packages -os: - - linux -r: - - oldrel - - release - - devel notifications: email: on_success: change on_failure: change + addons: apt: packages: - - texlive-xetex - - texlive-latex-extra - - texlive-fonts-recommended - - texlive-pictures - - ghostscript - - qpdf -r_packages: - - covr -r_build_args: --compact-vignettes=gs+qpdf + - make + +install: + - make build + +script: + - make check test + after_success: - - test "$TRAVIS_R_VERSION_STRING" = "release" && Rscript -e 'covr::codecov()' || true + - make covr diff --git a/DESCRIPTION b/DESCRIPTION index a73adb9..842e306 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,5 +40,5 @@ Suggests: SystemRequirements: pgf (>= 2.00) LazyLoad: yes VignetteBuilder: knitr -RoxygenNote: 6.1.0 +RoxygenNote: 6.1.1 Roxygen: list(markdown = TRUE) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0936eb0 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +SUDO := $(shell groups | grep -q docker || echo sudo -E) +IMAGE := "tikzdevice/ci" +PWD := $(shell pwd) +UID := $(shell id -u):$(shell id -g) + +DOCKER_OPTS := --rm -u $(UID) -e HOME=/tmp -v $(PWD):/mnt -w /mnt + +PKG_VERSION = $(shell grep -i ^version DESCRIPTION | cut -d : -d \ -f 2) +PKG_NAME = $(shell grep -i ^package DESCRIPTION | cut -d : -d \ -f 2) +PKG_TAR = $(PKG_NAME)_$(PKG_VERSION).tar.gz + +all: build check test clean + +docker-build: + $(SUDO) docker build -t $(IMAGE) docker + +docker-pull: + $(SUDO) docker pull $(IMAGE) + +docker-push: + $(SUDO) docker push $(IMAGE) + + +info: + $(SUDO) docker run $(DOCKER_OPTS) $(IMAGE) Rscript -e "sessionInfo()" + +build: + $(SUDO) docker run $(DOCKER_OPTS) $(IMAGE) R CMD build --compact-vignettes=gs+qpdf . + +check: + $(SUDO) docker run $(DOCKER_OPTS) $(IMAGE) R CMD check --no-manual $(PKG_TAR) + +test: + $(SUDO) docker run $(DOCKER_OPTS) $(IMAGE) Rscript -e \ + 'install.packages("$(PKG_TAR)", repos = NULL); testthat::test_dir("tests", stop_on_failure = TRUE)' + +covr: + $(SUDO) docker run $(DOCKER_OPTS) -e CODECOV_TOKEN $(IMAGE) Rscript -e "covr::codecov()" + +clean: + rm -rf $(PKG_TAR) $(PKG_NAME).Rcheck/ diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..043e70e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,29 @@ +FROM rocker/r-ver:latest + +LABEL org.label-schema.license="GPL-2.0" \ + org.label-schema.vcs-url="https://github.com/daqana/tikzDevice" \ + maintainer="Ralf Stubner " + +RUN apt-get update \ + && apt-get install --yes --no-install-recommends \ + ghostscript \ + git \ + imagemagick \ + libcurl4-openssl-dev \ + libpng-dev \ + libssl-dev \ + perl \ + qpdf \ + texinfo \ + wget \ + && wget -qO- "https://yihui.name/gh/tinytex/tools/install-unx.sh" \ + | sh -s - --admin --no-path \ + && mv ~/.TinyTeX /usr/local/tinytex \ + && /usr/local/tinytex/bin/*/tlmgr path add \ + && tlmgr install pgf preview xcolor memoir ifetex microtype float \ + babel-english listings xstring luatex85 \ + && install2.r filehash png evaluate formatR ggplot2 knitr lattice maps \ + testthat tinytex covr \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/* \ + && chmod 777 /usr/local/lib/R/site-library diff --git a/src/tikzDevice.c b/src/tikzDevice.c index 42b40f4..f27fe30 100644 --- a/src/tikzDevice.c +++ b/src/tikzDevice.c @@ -1368,14 +1368,22 @@ static void TikZ_Polyline( int n, double *x, double *y, /* End options, print first set of coordinates. */ printOutput(tikzInfo, "] (%6.2f,%6.2f) --\n", - x[0],y[0]); + x[0],y[0]); + + /*Show only for debugging*/ + if(tikzInfo->debug == TRUE) + printOutput(tikzInfo, "%% First point x = %f, y = %f\n", x[0],y[0]); /* Print coordinates for the middle segments of the line. */ int i; for ( i = 1; i < n-1; i++ ){ printOutput(tikzInfo, "\t(%6.2f,%6.2f) --\n", - x[i],y[i]); + x[i],y[i]); + + /*Show only for debugging*/ + if(tikzInfo->debug == TRUE) + printOutput(tikzInfo, "%% Next point x = %f, y = %f\n", x[i],y[i]); } @@ -1383,6 +1391,10 @@ static void TikZ_Polyline( int n, double *x, double *y, printOutput(tikzInfo, "\t(%6.2f,%6.2f);\n", x[n-1],y[n-1]); + /*Show only for debugging*/ + if(tikzInfo->debug == TRUE) + printOutput(tikzInfo, "%% Final point x = %f, y = %f\n", x[n-1],y[n-1]); + /*Show only for debugging*/ if(tikzInfo->debug == TRUE) printOutput(tikzInfo, @@ -1415,6 +1427,10 @@ static void TikZ_Polygon( int n, double *x, double *y, printOutput(tikzInfo, "] (%6.2f,%6.2f) --\n", x[0],y[0]); + /*Show only for debugging*/ + if(tikzInfo->debug == TRUE) + printOutput(tikzInfo, "%% First point x = %f, y = %f\n", x[0],y[0]); + /* Print coordinates for the middle segments of the line. */ int i; for ( i = 1; i < n; i++ ){ @@ -1422,6 +1438,10 @@ static void TikZ_Polygon( int n, double *x, double *y, printOutput(tikzInfo, "\t(%6.2f,%6.2f) --\n", x[i],y[i]); + /*Show only for debugging*/ + if(tikzInfo->debug == TRUE) + printOutput(tikzInfo, "%% Next point x = %f, y = %f\n", x[i],y[i]); + } /* End path by cycling to first set of coordinates. */ @@ -1430,7 +1450,7 @@ static void TikZ_Polygon( int n, double *x, double *y, /*Show only for debugging*/ if(tikzInfo->debug == TRUE) printOutput(tikzInfo, - "%% End Polyline\n"); + "%% End Polygon\n"); } diff --git a/tests/testthat/helper_graphics.R b/tests/testthat/helper_graphics.R index 4723b4b..096bfd9 100644 --- a/tests/testthat/helper_graphics.R +++ b/tests/testthat/helper_graphics.R @@ -127,11 +127,10 @@ compare_graph <- function(graph_name, tags) { return(TRUE) } - # Normalize and quote some paths in case we are running on Windows compare_output <- file.path(test_work_dir, paste0(graph_name, "_diff.png")) command_line <- paste( - shQuote(compare_cmd), "-density 300", "-metric AE", + shQuote(compare_cmd), "-density 300", "-metric AE", "-quiet", shQuote(test_output), shQuote(standard_graph), shQuote(compare_output), "2>&1 | awk '{metric=$NF};END{print metric}'" ) diff --git a/tests/testthat/standard_graphs/ggplot2_superscripts.pdf b/tests/testthat/standard_graphs/ggplot2_superscripts.pdf index a8f4f7c..52f3406 100644 Binary files a/tests/testthat/standard_graphs/ggplot2_superscripts.pdf and b/tests/testthat/standard_graphs/ggplot2_superscripts.pdf differ diff --git a/tests/testthat/standard_graphs/ggplot2_test.pdf b/tests/testthat/standard_graphs/ggplot2_test.pdf index ff297cb..d644dee 100644 Binary files a/tests/testthat/standard_graphs/ggplot2_test.pdf and b/tests/testthat/standard_graphs/ggplot2_test.pdf differ diff --git a/tests/testthat/standard_graphs/luatex_utf8_characters.pdf b/tests/testthat/standard_graphs/luatex_utf8_characters.pdf index a342154..dd350ba 100644 Binary files a/tests/testthat/standard_graphs/luatex_utf8_characters.pdf and b/tests/testthat/standard_graphs/luatex_utf8_characters.pdf differ diff --git a/tests/testthat/standard_graphs/utf8_characters.pdf b/tests/testthat/standard_graphs/utf8_characters.pdf index ba0e00e..492528e 100644 Binary files a/tests/testthat/standard_graphs/utf8_characters.pdf and b/tests/testthat/standard_graphs/utf8_characters.pdf differ diff --git a/tests/testthat/test_metrics_dict.R b/tests/testthat/test_metrics_dict.R index 54eae51..08ad01f 100644 --- a/tests/testthat/test_metrics_dict.R +++ b/tests/testthat/test_metrics_dict.R @@ -4,8 +4,8 @@ test_that("Temporary metrics dictionary is created, but only once", { expect_equal(getOption("tikzMetricsDictionary"), NULL) rm(list = ls(envir = .tikzInternal), envir = .tikzInternal) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = TRUE)) expect_true(file.exists(.tikzInternal[["db_file"]])) }) @@ -13,8 +13,8 @@ test_that("Silent creation of temporary metrics dictionary", { expect_equal(getOption("tikzMetricsDictionary"), NULL) rm(list = ls(envir = .tikzInternal), envir = .tikzInternal) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) + expect_silent(checkDictionaryStatus(verbose = FALSE)) + expect_silent(checkDictionaryStatus(verbose = FALSE)) expect_true(file.exists(.tikzInternal[["db_file"]])) }) @@ -27,23 +27,23 @@ test_that("Switching metrics dictionary", { tryCatch( { options(tikzMetricsDictionary = tempA) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = tempB) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = tempA) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Using")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Using") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = tempB) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Using")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Using") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = tempA) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) + expect_silent(checkDictionaryStatus(verbose = FALSE)) + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = tempB) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) - expect_that(checkDictionaryStatus(verbose = FALSE), not(shows_message())) + expect_silent(checkDictionaryStatus(verbose = FALSE)) + expect_silent(checkDictionaryStatus(verbose = FALSE)) }, finally = { options(tikzMetricsDictionary = NULL) @@ -61,17 +61,17 @@ test_that("Turning custom metrics dictionary on and off", { tryCatch( { options(tikzMetricsDictionary = temp) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = NULL) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = temp) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Using")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Using") + expect_silent(checkDictionaryStatus(verbose = FALSE)) options(tikzMetricsDictionary = NULL) - expect_that(checkDictionaryStatus(verbose = TRUE), shows_message("Creating")) - expect_that(checkDictionaryStatus(verbose = TRUE), not(shows_message())) + expect_message(checkDictionaryStatus(verbose = TRUE), "Creating") + expect_silent(checkDictionaryStatus(verbose = FALSE)) }, finally = { options(tikzMetricsDictionary = NULL)