Make Pstore tests as optional

This commit is contained in:
Hiroshi SHIBATA 2025-01-09 13:27:56 +09:00
parent 1089282acc
commit 3185550623
Notes: git 2025-01-10 01:20:01 +00:00
4 changed files with 23 additions and 12 deletions

View File

@ -11,7 +11,10 @@
# cgi/session.rb for more details on session storage managers.
require_relative '../session'
require 'pstore'
begin
require 'pstore'
rescue LoadError
end
class CGI
class Session
@ -82,7 +85,7 @@ class CGI
File::unlink path
end
end
end if defined?(::PStore)
end
end
# :enddoc:

View File

@ -91,7 +91,7 @@ class CGISessionTest < Test::Unit::TestCase
assert_equal(value1,session["key1"])
assert_equal(value2,session["key2"])
session.close
end
end if defined?(::PStore)
def test_cgi_session_specify_session_id
update_env(
'REQUEST_METHOD' => 'GET',

View File

@ -23,14 +23,18 @@ module Psych
class YAMLStoreTest < TestCase
def setup
@dir = Dir.mktmpdir("rubytest-file")
File.chown(-1, Process.gid, @dir)
@yamlstore_file = make_tmp_filename("yamlstore")
@yamlstore = YAML::Store.new(@yamlstore_file)
if defined?(::PStore)
@dir = Dir.mktmpdir("rubytest-file")
File.chown(-1, Process.gid, @dir)
@yamlstore_file = make_tmp_filename("yamlstore")
@yamlstore = YAML::Store.new(@yamlstore_file)
else
omit "PStore is not available"
end
end
def teardown
FileUtils.remove_entry_secure @dir
FileUtils.remove_entry_secure(@dir) if @dir
end
def make_tmp_filename(prefix)
@ -97,5 +101,5 @@ module Psych
end
end
end
end
end if defined?(::PStore)
end if defined?(Psych)

View File

@ -5,8 +5,12 @@ require 'tmpdir'
class YAMLStoreTest < Test::Unit::TestCase
def setup
@yaml_store_file = File.join(Dir.tmpdir, "yaml_store.tmp.#{Process.pid}")
@yaml_store = YAML::Store.new(@yaml_store_file)
if defined?(::PStore)
@yaml_store_file = File.join(Dir.tmpdir, "yaml_store.tmp.#{Process.pid}")
@yaml_store = YAML::Store.new(@yaml_store_file)
else
omit "PStore is not available"
end
end
def teardown
@ -177,4 +181,4 @@ class YAMLStoreTest < Test::Unit::TestCase
end
assert_equal(indentation_3_yaml, File.read(@yaml_store_file), bug12800)
end
end if defined?(::YAML::Store)
end