Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texinputs #203

Merged
merged 3 commits into from
Jan 12, 2020
Merged
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Encoding: UTF-8
Package: tikzDevice
Type: Package
Title: R Graphics Output in LaTeX Format
Version: 0.12.3
Version: 0.12.3.1
Authors@R: c( person("Charlie", "Sharpsteen", role = "aut"),
person("Cameron", "Bracken", role = "aut"), person("Kirill",
"Müller", role = c("ctb"), email =
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# tikzDevice 0.12.3.1 (unreleased)

Bug fixes
---------

- current working directory is added to TEXINPUTS (#198)



# tikzDevice 0.12.3 (2019-08-07)

Bug fixes
Expand Down
5 changes: 4 additions & 1 deletion R/latexStrWidth.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ getMetricsFromLatex <- function(TeXMetrics, verbose = verbose, diagnose = FALSE)
texDir <- tempfile("tikzDevice")
dir.create(texDir)
oldwd <- getwd()
on.exit(setwd(oldwd))
tex_inputs <- Sys.getenv("TEXINPUTS")
on.exit(Sys.setenv(TEXINPUTS = tex_inputs))
Sys.setenv(TEXINPUTS = paste(oldwd, tex_inputs, sep = .Platform$path.sep))
on.exit(setwd(oldwd), add = TRUE)
setwd(texDir)
texLog <- "tikzStringWidthCalc.log"
texFile <- "tikzStringWidthCalc.tex"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/helper_graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ compare_graph <- function(graph_name, tags) {
# 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
5 changes: 2 additions & 3 deletions tests/testthat/test_error_handling.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
context("Test tikzDevice error and warning messages")

test_that("Null device is not a tikzDevice", {
expect_that(
suppressMessages(isTikzDevice()),
is_false()
expect_false(
suppressMessages(isTikzDevice())
)
})

Expand Down
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 = TRUE))
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 = TRUE))
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 = TRUE))
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 = TRUE))
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 = TRUE))
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 = TRUE))
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 = TRUE))
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 = TRUE))
},
finally = {
options(tikzMetricsDictionary = NULL)
Expand Down