Module: Megatest
- Defined in:
- lib/megatest/queue.rb,
lib/megatest.rb,
lib/megatest/cli.rb,
lib/megatest/dsl.rb,
lib/megatest/test.rb,
lib/megatest/state.rb,
lib/megatest/stubs.rb,
lib/megatest/compat.rb,
lib/megatest/config.rb,
lib/megatest/differ.rb,
lib/megatest/output.rb,
lib/megatest/runner.rb,
lib/megatest/runtime.rb,
lib/megatest/version.rb,
lib/megatest/executor.rb,
lib/megatest/selector.rb,
lib/megatest/backtrace.rb,
lib/megatest/reporters.rb,
lib/megatest/test_task.rb,
lib/megatest/assertions.rb,
lib/megatest/subprocess.rb,
lib/megatest/redis_queue.rb,
lib/megatest/pretty_print.rb,
lib/megatest/multi_process.rb,
lib/megatest/patience_diff.rb,
lib/megatest/queue_monitor.rb,
lib/megatest/queue_reporter.rb
Overview
Defined Under Namespace
Modules: Assertions, Compat, DSL, MultiProcess, PatienceDiff, Reporters, ShardeableQueue, State, Stubs
Classes: AbstractExecutor, AbstractQueue, Assertion, Backtrace, CIService, CLI, CircuitBreaker, Config, Differ, Executor, Failure, FileQueue, LostTest, NoAssertion, Output, PrettyPrint, Queue, QueueMonitor, QueueReporter, RedisQueue, Registry, Runner, Runtime, Selector, Stubber, Subprocess, Test, TestCaseResult, TestTask, UnexpectedError
Constant Summary
collapse
- Error =
Class.new(StandardError)
- AlreadyDefinedError =
Class.new(Error)
- LoadError =
Class.new(Error)
- ROOT =
-File.expand_path("../", __FILE__)
- PWD =
File.join(Dir.pwd, "/")
- IGNORED_ERRORS =
[NoMemoryError, SignalException, SystemExit].freeze
- DEFAULT_TEST_GLOB =
"**/{test_*,*_test}.rb"
- VERSION =
"0.8.0"
- DidNotRun =
Class.new(Assertion)
- Skip =
Class.new(Assertion)
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.config {|@config| ... } ⇒ Object
132
133
134
135
|
# File 'lib/megatest/config.rb', line 132
def config
yield @config if block_given?
@config
end
|
.running ⇒ Object
Returns the value of attribute running.
20
21
22
|
# File 'lib/megatest.rb', line 20
def running
@running
end
|
Class Method Details
.append_load_path(config) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/megatest.rb', line 34
def append_load_path(config)
config.load_paths.each do |path|
abs_path = File.absolute_path(path)
$LOAD_PATH.unshift(abs_path) unless $LOAD_PATH.include?(abs_path)
end
end
|
.fork? ⇒ Boolean
22
23
24
|
# File 'lib/megatest.rb', line 22
def fork?
Process.respond_to?(:fork) && !ENV["NO_FORK"]
end
|
.init(config) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/megatest.rb', line 41
def init(config)
if config.deprecations && ::Warning.respond_to?(:[]=)
::Warning[:deprecated] = true
end
Random.srand(config.seed)
end
|
.load_config(config) ⇒ Object
67
68
69
|
# File 'lib/megatest.rb', line 67
def load_config(config)
load_files(config.selectors.main_paths, "test_config.rb")
end
|
.load_files(paths, name) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/megatest.rb', line 75
def load_files(paths, name)
scanned = {}
paths.each do |path|
path = File.dirname(path) unless File.directory?(path)
while path.start_with?(PWD)
break if scanned[path]
scanned[path] = true
config_path = File.join(path, name)
if File.exist?(config_path)
require(config_path)
break
end
path = File.dirname(path)
end
end
nil
end
|
.load_test_helper(paths) ⇒ Object
71
72
73
|
# File 'lib/megatest.rb', line 71
def load_test_helper(paths)
load_files(paths, "test_helper.rb")
end
|
.load_tests(config, paths = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/megatest.rb', line 51
def load_tests(config, paths = nil)
registry = with_registry do
append_load_path(config)
load_test_helper(config.selectors.main_paths)
paths ||= config.selectors.paths(random: config.random)
paths.each do |path|
Kernel.require(path)
rescue LoadError
raise InvalidArgument, "Failed to load #{relative_path(path)}"
end
end
config.selectors.select(registry, random: config.random)
end
|
.now ⇒ Object
26
27
28
|
# File 'lib/megatest.rb', line 26
def now
Process.clock_gettime(Process::CLOCK_REALTIME)
end
|
.registry ⇒ Object
9
10
11
12
13
|
# File 'lib/megatest/state.rb', line 9
def registry
raise Error, "Can't define tests without a registry set" unless @registry
@registry
end
|
.relative_path(absolute_path) ⇒ Object
30
31
32
|
# File 'lib/megatest.rb', line 30
def relative_path(absolute_path)
absolute_path&.delete_prefix(PWD)
end
|
.with_registry(registry = Registry.new) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/megatest/state.rb', line 15
def with_registry(registry = Registry.new)
@registry = registry
begin
yield
ensure
@registry = nil
end
registry
end
|
Instance Method Details
#glob(pattern) ⇒ Object
98
99
100
|
# File 'lib/megatest.rb', line 98
def glob(pattern)
Dir.glob(pattern)
end
|