ftest 0.3.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ftest.rb +1 -0
- data/lib/ftest/assert/assertion.rb +1 -1
- data/lib/ftest/cli.rb +14 -18
- data/lib/ftest/config.rb +9 -7
- data/lib/ftest/runner.rb +12 -5
- metadata +17 -4
- data/lib/ftest/colored_logger.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5738d3080893d015b14e3ce706c0d4dab1f20319
|
4
|
+
data.tar.gz: c4ae4ac2674e3afcd9b0fabc1e8dd8cc0e0f7aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516e5a0a8d5910a9347b4e09eb12f25e6226fc76d2a4e8ba31acd56d2d960e37cc4b17e2c9aa627422287d085a71a58a1ae5bf7a35743154c472aa03709c9d11
|
7
|
+
data.tar.gz: aa759bfee38c2c92ab08da83ae723a1e30c3501a87335e5d56d3a09cf2c61656a2078a538cb7f644991c199aeb54b0060d66686a08796168b7a56816ebe338bc
|
data/lib/ftest.rb
CHANGED
@@ -22,7 +22,7 @@ module FTest
|
|
22
22
|
|
23
23
|
def build_checks
|
24
24
|
@checks.map do |check_name, argument|
|
25
|
-
FTest.
|
25
|
+
FTest::Config.internal_logger.debug "Resolving check #{check_name.inspect}, arg=#{argument.inspect}"
|
26
26
|
resolve_check check_name, argument
|
27
27
|
end
|
28
28
|
end
|
data/lib/ftest/cli.rb
CHANGED
@@ -16,7 +16,6 @@ module FTest
|
|
16
16
|
|
17
17
|
def call
|
18
18
|
@options = ArgvParser.(@argv)
|
19
|
-
options.color if @stdout.tty?
|
20
19
|
setup_config
|
21
20
|
Runner.(resolve_files) or exit 1
|
22
21
|
end
|
@@ -30,9 +29,9 @@ module FTest
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def build_logger
|
33
|
-
|
34
|
-
logger = cls.new @stdout
|
32
|
+
logger = Logger.new @stdout
|
35
33
|
logger.level = options.log_level
|
34
|
+
logger.progname = "ftest"
|
36
35
|
logger
|
37
36
|
end
|
38
37
|
|
@@ -47,13 +46,22 @@ module FTest
|
|
47
46
|
end
|
48
47
|
|
49
48
|
class Options
|
49
|
+
def self.build
|
50
|
+
if ENV["FTEST_VERBOSE"]
|
51
|
+
log_level = Logger::DEBUG
|
52
|
+
else
|
53
|
+
log_level = Logger::INFO
|
54
|
+
end
|
55
|
+
new log_level
|
56
|
+
end
|
57
|
+
|
50
58
|
attr_reader :child_count
|
51
59
|
attr_reader :log_level
|
52
60
|
attr_reader :paths
|
53
61
|
|
54
|
-
def initialize
|
62
|
+
def initialize log_level
|
55
63
|
@paths = []
|
56
|
-
@log_level =
|
64
|
+
@log_level = log_level
|
57
65
|
end
|
58
66
|
|
59
67
|
def add_path path
|
@@ -64,14 +72,6 @@ module FTest
|
|
64
72
|
@child_count = number.to_i
|
65
73
|
end
|
66
74
|
|
67
|
-
def color
|
68
|
-
@color = !@color
|
69
|
-
end
|
70
|
-
|
71
|
-
def color?
|
72
|
-
@color
|
73
|
-
end
|
74
|
-
|
75
75
|
def fail_fast
|
76
76
|
@fail_fast = !@fail_fast
|
77
77
|
end
|
@@ -108,7 +108,7 @@ module FTest
|
|
108
108
|
|
109
109
|
class ArgvParser
|
110
110
|
def self.call argv
|
111
|
-
options = Options.
|
111
|
+
options = Options.build
|
112
112
|
parser = ArgvParser.new argv, options
|
113
113
|
parser.()
|
114
114
|
options
|
@@ -144,10 +144,6 @@ If no PATH(s) are specified, ./tests is assumed
|
|
144
144
|
@options.full_backtrace
|
145
145
|
end
|
146
146
|
|
147
|
-
opts.on "-c", "--color", "Enable/disable colored output" do
|
148
|
-
@options.color
|
149
|
-
end
|
150
|
-
|
151
147
|
opts.on "-f", "--fail-fast", "When any test script fails, exit immediately" do
|
152
148
|
@options.fail_fast
|
153
149
|
end
|
data/lib/ftest/config.rb
CHANGED
@@ -2,9 +2,11 @@ module FTest
|
|
2
2
|
module Config
|
3
3
|
extend self
|
4
4
|
|
5
|
+
extend Logger::Logging
|
6
|
+
|
5
7
|
attr_writer :child_count
|
6
8
|
attr_writer :fail_fast
|
7
|
-
attr_writer :
|
9
|
+
attr_writer :internal_logger
|
8
10
|
attr_writer :reverse_backtraces
|
9
11
|
attr_writer :trim_backtraces
|
10
12
|
|
@@ -20,12 +22,12 @@ module FTest
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def internal_logger
|
26
|
+
if ENV["FTEST_INTERNAL_LOGGING"]
|
27
|
+
logger
|
28
|
+
else
|
29
|
+
Logger::Logging::NullLogger
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def reverse_backtraces
|
data/lib/ftest/runner.rb
CHANGED
@@ -13,10 +13,17 @@ module FTest
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
Config.
|
16
|
+
Config.internal_logger.debug "ftest found #{files.size} files: #{files * ", "}"
|
17
17
|
return if files.empty?
|
18
18
|
result = run_all
|
19
|
-
|
19
|
+
|
20
|
+
log_msg = "finished executing files; success=#{result.inspect}"
|
21
|
+
if result
|
22
|
+
Config.logger.info log_msg
|
23
|
+
else
|
24
|
+
Config.logger.warn log_msg
|
25
|
+
end
|
26
|
+
|
20
27
|
result
|
21
28
|
end
|
22
29
|
|
@@ -63,7 +70,7 @@ module FTest
|
|
63
70
|
def reap reads
|
64
71
|
@set.delete_if do |process|
|
65
72
|
next unless reads.include? process.fd
|
66
|
-
Config.
|
73
|
+
Config.internal_logger.debug "Reaping #{process.file}:#{process.pid}"
|
67
74
|
process.finish or @passed = false
|
68
75
|
true
|
69
76
|
end
|
@@ -120,7 +127,7 @@ module FTest
|
|
120
127
|
locations = FTest::BacktraceFilter.(locations)
|
121
128
|
|
122
129
|
lines = locations.map do |loc| "\tfrom #{loc}" end
|
123
|
-
lines.unshift "#{final_location}: #{error.message}"
|
130
|
+
lines.unshift "#{final_location}: #{error.message} (#{error.class.name})"
|
124
131
|
|
125
132
|
lines.reverse! if Config.reverse_backtraces
|
126
133
|
Config.logger.error "Exception:\n#{lines * "\n"}"
|
@@ -130,7 +137,7 @@ module FTest
|
|
130
137
|
fd.read 1
|
131
138
|
_, status = ::Process.wait2 pid
|
132
139
|
status = status.exitstatus
|
133
|
-
Config.
|
140
|
+
Config.internal_logger.debug "finished script #{@file}; status=#{status.inspect}"
|
134
141
|
status == 0
|
135
142
|
end
|
136
143
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ftest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
12
|
-
dependencies:
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logger-logging
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Fork based runner for tests written as simple ruby scripts
|
14
28
|
email: nathanladd+github@gmail.com
|
15
29
|
executables:
|
@@ -28,7 +42,6 @@ files:
|
|
28
42
|
- lib/ftest/assert/syntax.rb
|
29
43
|
- lib/ftest/backtrace_filter.rb
|
30
44
|
- lib/ftest/cli.rb
|
31
|
-
- lib/ftest/colored_logger.rb
|
32
45
|
- lib/ftest/config.rb
|
33
46
|
- lib/ftest/runner.rb
|
34
47
|
- lib/ftest/script.rb
|
data/lib/ftest/colored_logger.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module FTest
|
2
|
-
class ColoredLogger
|
3
|
-
ANSI_COLORS = %i(black red green yellow blue magenta cyan white)
|
4
|
-
|
5
|
-
DEFAULT_PALETTE = {
|
6
|
-
:unknown => -> msg { bg(:blue, :bright, fg(:white, :bright, msg)) },
|
7
|
-
:fatal => -> msg { bg(:red, :bright, fg(:white, :bright, msg)) },
|
8
|
-
:error => -> msg { fg(:red, :bright, msg) },
|
9
|
-
:warn => -> msg { fg(:yellow, :bright, msg) },
|
10
|
-
:info => -> msg { fg(:default, :normal, msg) },
|
11
|
-
:debug => -> msg { fg(:cyan, :bright, msg) },
|
12
|
-
}
|
13
|
-
|
14
|
-
attr_reader :palette
|
15
|
-
|
16
|
-
def initialize io, palette = DEFAULT_PALETTE
|
17
|
-
@logger = Logger.new io
|
18
|
-
@palette = palette
|
19
|
-
end
|
20
|
-
|
21
|
-
%i(level= progname=).each do |method_name|
|
22
|
-
define_method method_name do |*args, &block|
|
23
|
-
@logger.public_send method_name, *args, &block
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
%i(unknown fatal error warn info debug).each do |log_level|
|
28
|
-
define_method log_level do |msg_or_progname = nil, &orig_block|
|
29
|
-
colored_msg = format log_level, msg_or_progname
|
30
|
-
|
31
|
-
if orig_block
|
32
|
-
progname = colored_msg
|
33
|
-
block = -> do format log_level, orig_block.() end
|
34
|
-
else
|
35
|
-
block = -> do colored_msg end
|
36
|
-
end
|
37
|
-
|
38
|
-
@logger.public_send log_level, progname, &block
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def format log_level, msg
|
43
|
-
formatter = palette.fetch log_level
|
44
|
-
instance_exec msg, &formatter
|
45
|
-
end
|
46
|
-
|
47
|
-
def fg *args
|
48
|
-
col :fg, *args
|
49
|
-
end
|
50
|
-
|
51
|
-
def bg *args
|
52
|
-
col :bg, *args
|
53
|
-
end
|
54
|
-
|
55
|
-
def col fgbg, color_code, intensity_code, str
|
56
|
-
color_num = ANSI_COLORS.index color_code
|
57
|
-
intensity_num = { :normal => 0, :bright => 1 }.fetch intensity_code
|
58
|
-
fgbg_num = { :fg => 3, :bg => 4 }.fetch fgbg
|
59
|
-
"\e[#{fgbg_num}#{color_num};#{intensity_num}m#{str}\e[0m"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|