From fb66dee707feffb46ffa79fd988c930fb8a76b7d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 9 Oct 2026 08:29:08 +0900 Subject: [PATCH] Write hexapdf and lee output to Dir.tmpdir On Windows /tmp is a directory at the root of the current drive, so both benchmarks fail with ENOENT unless someone has created it. Co-Authored-By: Claude Opus 5.5 --- benchmarks/hexapdf/benchmark.rb | 9 ++++++--- benchmarks/lee/benchmark.rb | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/benchmarks/hexapdf/benchmark.rb b/benchmarks/hexapdf/benchmark.rb index 9609139b..bcd2cf90 100644 --- a/benchmarks/hexapdf/benchmark.rb +++ b/benchmarks/hexapdf/benchmark.rb @@ -9,6 +9,7 @@ require "hexapdf" require "fileutils" +require "tmpdir" IN_FILENAME = "odyssey.txt" WIDTH = 50 @@ -16,7 +17,8 @@ EXPECTED_SIZE = 569797 -Dir["/tmp/hexapdf-result*.pdf"].each { |file| FileUtils.rm file } +OUT_DIR = Dir.tmpdir.freeze +Dir.glob("hexapdf-result*.pdf", base: OUT_DIR).each { |file| FileUtils.rm File.join(OUT_DIR, file) } if ENV["RUBY_BENCH_RACTOR_HARNESS"] make_shareable(HexaPDF::DefaultDocumentConfiguration) @@ -36,7 +38,7 @@ # Non-TTF benchmark iter += 1 - out_filename = "/tmp/hexapdf-result-#{ "%03d" % iter }.pdf" + out_filename = File.join(OUT_DIR, "hexapdf-result-#{ "%03d" % iter }.pdf") composer = HexaPDF::Composer.new(page_size: [0, 0, WIDTH, HEIGHT], margin: 0) @@ -47,7 +49,8 @@ composer.write(out_filename, update_fields: false) end -Dir["/tmp/hexapdf-result*.pdf"].each do |file| +Dir.glob("hexapdf-result*.pdf", base: OUT_DIR).each do |name| + file = File.join(OUT_DIR, name) sz = File.stat(file).size raise "Incorrect size #{sz} for file #{file} (expected #{EXPECTED_SIZE})!" unless sz == EXPECTED_SIZE FileUtils.rm file diff --git a/benchmarks/lee/benchmark.rb b/benchmarks/lee/benchmark.rb index 2abdd945..5d0475fc 100644 --- a/benchmarks/lee/benchmark.rb +++ b/benchmarks/lee/benchmark.rb @@ -4,12 +4,13 @@ # we don't run "bundle install" above. require_relative 'lib/lee' +require 'tmpdir' #board_filename, output_filename, expansions_dir, *rest = ARGV #raise 'no input filename' unless board_filename #raise 'too many arguments' unless rest.empty? board_filename = File.dirname(__FILE__) + "/inputs/testBoard.txt" -output_filename = "/tmp/testBoard.svg" +output_filename = File.join(Dir.tmpdir, "testBoard.svg") expansions_dir = nil if expansions_dir