tf 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/lib/plugins/tf/env_arr_test.rb +4 -3
- data/lib/plugins/tf/env_match_test.rb +3 -2
- data/lib/plugins/tf/env_type_test.rb +1 -1
- data/lib/tf/environment.rb +12 -8
- metadata +3 -3
data/README.md
CHANGED
@@ -60,6 +60,12 @@ Still only Bash / ZSH like shells are allowed.
|
|
60
60
|
# passed: status != 1
|
61
61
|
##### Processed commands 2 of 2, success tests 2 of 3, failure tests 1 of 3.
|
62
62
|
|
63
|
+
## Troubleshooting
|
64
|
+
|
65
|
+
Use environment variable `TF_DEBUG` to enable additional logging:
|
66
|
+
|
67
|
+
TF_DEBUG=1 tf --text example_tests/comment/*
|
68
|
+
|
63
69
|
## Internal architecture
|
64
70
|
|
65
71
|
Framework will load plugins from any available gem and local `lib/` path, for example:
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class TF::EnvArrTest
|
2
2
|
MATCHER = {
|
3
|
-
:all => /^env\[(
|
4
|
-
:one => /^env\[(
|
5
|
-
:size => /^env\[(
|
3
|
+
:all => /^env\[([a-zA-Z_][a-zA-Z0-9_]*)\]\[\]([!]?=)[~]?\/(.*)\/$/,
|
4
|
+
:one => /^env\[([a-zA-Z_][a-zA-Z0-9_]*)\]\[(.+)\]([!]?=)[~]?\/(.*)\/$/,
|
5
|
+
:size => /^env\[([a-zA-Z_][a-zA-Z0-9_]*)\]\[\]([!]?=)([[:digit:]]+)$/,
|
6
6
|
}
|
7
7
|
|
8
8
|
def matches? test
|
@@ -12,6 +12,7 @@ class TF::EnvArrTest
|
|
12
12
|
|
13
13
|
def execute test, _stdout, _stderr, _stdboth, _status, env
|
14
14
|
type, matcher = TF::EnvArrTest::MATCHER.find{|k,v| test =~ v }
|
15
|
+
$stderr.puts "EnvArrTest: #{type}." if ENV["TF_DEBUG"]
|
15
16
|
send "execute_#{type}".to_sym, matcher, test, _stdout, _stderr, _stdboth, _status, env
|
16
17
|
end
|
17
18
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class TF::EnvMatchTest
|
2
|
-
MATCHER = /^env\[(
|
2
|
+
MATCHER = /^env\[([a-zA-Z_][a-zA-Z0-9_]*)\]([!]?=)[~]?\/(.*)\/$/
|
3
3
|
|
4
4
|
def matches? test
|
5
5
|
test =~ TF::EnvMatchTest::MATCHER
|
@@ -9,7 +9,8 @@ class TF::EnvMatchTest
|
|
9
9
|
test =~ TF::EnvMatchTest::MATCHER
|
10
10
|
variable, sign, value = $1.strip, $2, $3
|
11
11
|
var_val = env[ variable ]
|
12
|
-
|
12
|
+
if !(var_val.nil?) && !(var_val.is_a?(String))
|
13
|
+
$stderr.puts "Not a string: #{var_val}, type:#{var_val.class}." if ENV["TF_DEBUG"]
|
13
14
|
return [ false, "failed: env #{variable} #{sign} /#{value}/ # not a string" ]
|
14
15
|
end
|
15
16
|
if ( sign == "=" ) ^ ( Regexp.new(value) =~ "#{var_val}" )
|
data/lib/tf/environment.rb
CHANGED
@@ -22,7 +22,7 @@ class TF::Environment
|
|
22
22
|
HANDLER=<<EOF.gsub(/\n/,'')
|
23
23
|
set | awk -F= '
|
24
24
|
BEGIN{v=0;}
|
25
|
-
/^[a-zA-Z_]
|
25
|
+
/^[a-zA-Z_][a-zA-Z0-9_]*=/{v=1;}
|
26
26
|
v==1&&$2~/^['\\''\\$]/{v=2;}
|
27
27
|
v==1&&$2~/^\\(/{v=3;}
|
28
28
|
v==2&&/'\\''$/&&!/'\\'\\''$/{v=1;}
|
@@ -41,14 +41,18 @@ EOF
|
|
41
41
|
terminator=nil
|
42
42
|
output.each do |line|
|
43
43
|
line.chomp!
|
44
|
-
if holder.nil?
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
if holder.nil?
|
45
|
+
if line =~ /^[^=]+=([\('\$]?)/
|
46
|
+
holder = line
|
47
|
+
if $1 && !$1.empty?
|
48
|
+
terminator = $1.sub(/\$/,"'").sub(/\(/,")")
|
49
|
+
end
|
50
|
+
elsif line =~ /^[^=]*=/
|
51
|
+
holder = line
|
52
|
+
terminator=nil
|
53
|
+
else
|
54
|
+
$stderr.puts "Unknown environment token: #{line}." if ENV["TF_DEBUG"]
|
48
55
|
end
|
49
|
-
elsif holder.nil? && line =~ /^[^=]*=/
|
50
|
-
holder = line
|
51
|
-
terminator=nil
|
52
56
|
else
|
53
57
|
holder += line
|
54
58
|
end
|
metadata
CHANGED