Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ cmake-build-debug$
^codecov\.yml$
^_pkgdown\.yml$
^docs$
^docker$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
/CMakeLists.txt
/clion-test.R
/cmake-build-debug/
*~
36 changes: 16 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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)
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/
29 changes: 29 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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
26 changes: 23 additions & 3 deletions src/tikzDevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,21 +1368,33 @@ 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]);

}

/* Print last set of coordinates. End path. */
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,
Expand Down Expand Up @@ -1415,13 +1427,21 @@ 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++ ){

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. */
Expand All @@ -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");

}

Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/helper_graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
)
Expand Down
Binary file modified tests/testthat/standard_graphs/ggplot2_superscripts.pdf
Binary file not shown.
Binary file modified tests/testthat/standard_graphs/ggplot2_test.pdf
Binary file not shown.
Binary file modified tests/testthat/standard_graphs/luatex_utf8_characters.pdf
Binary file not shown.
Binary file modified tests/testthat/standard_graphs/utf8_characters.pdf
Binary file not shown.
48 changes: 24 additions & 24 deletions tests/testthat/test_metrics_dict.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ 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"]]))
})

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"]]))
})

Expand All @@ -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)
Expand All @@ -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)
Expand Down