Skip to content

Commit

Permalink
fix: Skip certain tests if ghostscript version > 9.55
Browse files Browse the repository at this point in the history
* ghostscript v10.3 breaks code to disable old bookmarks
* Now skip tests that verify old bookmarks disabled if detects
  ghostscript version is strictly greater than 9.55

see #59
  • Loading branch information
trevorld committed Mar 28, 2024
1 parent 8620f49 commit 35999c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
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: xmpdf
Type: Package
Title: Edit 'XMP' Metadata and 'PDF' Bookmarks and Documentation Info
Version: 0.2.0-0
Version: 0.2.0-1
Description: Edit 'XMP' metadata <https://en.wikipedia.org/wiki/Extensible_Metadata_Platform>
in a variety of media file formats as well as
edit bookmarks (aka outline aka table of contents) and documentation info entries in 'pdf' files.
Expand Down
2 changes: 1 addition & 1 deletion R/bookmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ set_bookmarks_gs <- function(bookmarks, input, output = input) {
shQuote(input),
shQuote(system.file("gs/pdfmark_restore.txt", package = "xmpdf")),
shQuote(metafile))
xmpdf_system2(cmd, args)
stdout <- xmpdf_system2(cmd, args)
if (input == output) {
file.copy(target, output, overwrite = TRUE)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-bookmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ test_that("set_bookmarks_gs", {
expect_equal(nrow(bm), 3L)
expect_equal(attr(bm, "total_pages"), 2L)

gs_version <- numeric_version(system2(find_gs_cmd(), "--version", stdout = TRUE))
skip_if_not(gs_version <= "9.55.0")

# Does Unicode work
skip_if_not(l10n_info()[["UTF-8"]])
skip_on_os("mac") # CRAN checks on macOS 14
Expand Down Expand Up @@ -174,6 +177,10 @@ test_that("bookmarks_pdftools", {
# Does Unicode work
skip_if_not(l10n_info()[["UTF-8"]])
skip_on_os("mac") # CRAN checks on macOS 14
if(supports_gs()) {
gs_version <- numeric_version(system2(find_gs_cmd(), "--version", stdout = TRUE))
skip_if_not(gs_version <= "9.55.0")
}
bookmarks <- data.frame(title = c("R\u5f88\u68d2\uff01", "Page 1", "Page 2"),
level = c(1, 2, 2),
page = c(1L, 1L, 2L))
Expand Down

0 comments on commit 35999c7

Please sign in to comment.