tf 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
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\[(.*)\]\[\]([!]?=)([[:digit:]]+)$/,
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
- unless var_val.is_a? String
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}" )
@@ -1,5 +1,5 @@
1
1
  class TF::EnvTypeTest
2
- MATCHER = /^env\[(.*)\]\?([!]?=)(array|string|nil)/
2
+ MATCHER = /^env\[([a-zA-Z_][a-zA-Z0-9_]*)\]\?([!]?=)(array|string|nil)/
3
3
 
4
4
  def matches? test
5
5
  test =~ TF::EnvTypeTest::MATCHER
@@ -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_]+=/{v=1;}
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? && line =~ /^[^=]+=([\('\$]?)/
45
- holder = line
46
- if $1 && !$1.empty?
47
- terminator = $1.sub(/\$/,"'").sub(/\(/,")")
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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michal Papis