This repository has been archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_helper.rb
88 lines (74 loc) · 1.95 KB
/
test_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require "test/unit"
require "rubygems"
require "mocha"
require "log4r"
require "fileutils"
begin
require "turn"
rescue LoadError
# NOP: ignore, this is not a real dependency
end
require File.expand_path("#{File.dirname(__FILE__)}/../config/requirements")
require File.expand_path("#{File.dirname(__FILE__)}/integration_helpers")
require "find"
module Test
module Unit
module Assertions
def deny(boolean, message = nil)
message = build_message message, '<?> is not false or nil.', boolean
assert_block message do
not boolean
end
end
end
end
end
class PistonTestCase < Test::Unit::TestCase
class << self
def logger
@@logger ||= Log4r::Logger["test"]
end
end
attr_reader :pathnames
def setup
super
@pathnames = []
end
def teardown
pathnames.each do |pathname|
pathname.rmtree if File.exists?(pathname)
end
super
end
def run(*args)
return if method_name.to_sym == :default_test
super
end
def mkpath(path_or_pathname)
if path_or_pathname.is_a?(Pathname)
raise ArgumentError, "#{path_or_pathname.inspect} must be absolute" unless path_or_pathname.absolute?
path = path_or_pathname
else
path = Pathname.new(File.expand_path(path_or_pathname))
end
path.mkpath
pathnames.push(path)
path
end
def logger
self.class.logger
end
end
LOG_DIR = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../log")) unless Object::const_defined?(:LOG_DIR)
LOG_DIR.mkdir rescue nil
Log4r::Logger.root.level = Log4r::DEBUG
Log4r::Logger.new("main")
Log4r::Logger.new("handler")
Log4r::Logger.new("handler::client")
Log4r::Logger.new("handler::client::out")
Log4r::Logger.new("test")
FileUtils.touch("#{LOG_DIR}/test.log")
Log4r::FileOutputter.new("log", :trunc => true, :filename => (LOG_DIR + "test.log").realpath.to_s)
Log4r::Logger["main"].add "log"
Log4r::Logger["handler"].add "log"
Log4r::Logger["test"].add "log"