cat("Stopping test widdlywiki server...\n") pid <- Sys.getenv("TEST_TIDDLYWIKI_SERVER_PID") if (nzchar(pid)) { tools::pskill(as.numeric(pid)) } cat("Cleanup tempory test folder") tw_folder <- test_folder() unlink(tw_folder, recursive = TRUE) # Clean up any remaining temporary directories that might have been created by external tools temp_base <- tempdir() if (dir.exists(temp_base)) { # Use the utility function for comprehensive cleanup rtiddlywiki:::.cleanup_calibre_temp(temp_base, verbose = TRUE) # Also clean up pandoc temp directories if any pandoc_files <- list.files(temp_base, pattern = "^pandoc", full.names = TRUE) if (length(pandoc_files) > 0) { cat("Cleaning up", length(pandoc_files), "pandoc temporary directories...\n") unlink(pandoc_files, recursive = TRUE) } }