grntest 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aee9882d86b34a5b1784921890c57144b581daa
4
- data.tar.gz: 07030943c58f7d7d76d0713d555c536dda782961
3
+ metadata.gz: 47043c20a22bc0d82dc943e99ea96448e9716666
4
+ data.tar.gz: dd45a3f47b2019028e5293277d7fa20fb3c2a793
5
5
  SHA512:
6
- metadata.gz: f6dc4dc972ad6a914839427cb165e4a08c76a9ee3ee63d25d89a680d74fcd41fc665f487851d9b94e24c534246299bb551bcb4d24cd1478e72d4c72eb79d10ed
7
- data.tar.gz: 4e90459f4b0b42412cb9d2215225ea42d9899388ed797182627881a52275b5e5fa70fb3d4c41d92045ace87d1f2b953ad8f12dc5a0b5c6207697137c9c094172
6
+ metadata.gz: 96837152fe115554dfc492c3594b52ed78f11cf0c567b188586563c7fe7cacd52ac0802573d4fdbb278eb55bcbdc88eba4c16936bff34a894b0571290db6d55e
7
+ data.tar.gz: 4bed50348dddc4d2d1bd264a65424a8b306d3ed1026b9a334fe0891a8e1322022d1f7f0e583807c50ede9a05bf9c8f514f8f4c35988d1239cf85d022c4284491
data/doc/text/news.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # News
2
2
 
3
+ ## 1.1.7: 2016-05-16
4
+
5
+ ### Improvements
6
+
7
+ * Added `timeout` directive.
8
+
9
+ * Supported defining environment variable by `#$NAME=VALUE` syntax.
10
+
3
11
  ## 1.1.6: 2016-04-27
4
12
 
5
13
  ### Improvements
@@ -39,6 +39,7 @@ module Grntest
39
39
  @pending_load_command = nil
40
40
  @current_command_name = nil
41
41
  @output_type = nil
42
+ @timeout = default_timeout
42
43
  @long_timeout = default_long_timeout
43
44
  @context = context
44
45
  @custom_important_log_levels = []
@@ -183,6 +184,29 @@ module Grntest
183
184
  FileUtils.cp_r(source.to_s, destination.to_s)
184
185
  end
185
186
 
187
+ def execute_directive_timeout(line, content, options)
188
+ timeout, = options
189
+ invalid_value_p = false
190
+ case timeout
191
+ when "default"
192
+ @timeout = default_timeout
193
+ when nil
194
+ invalid_value_p = true
195
+ else
196
+ begin
197
+ @timeout = Float(timeout)
198
+ rescue ArgumentError
199
+ invalid_value_p = true
200
+ end
201
+ end
202
+
203
+ if invalid_value_p
204
+ log_input(line)
205
+ message = "timeout must be number or 'default': <#{timeout}>"
206
+ log_error("#|e| [timeout] #{message}")
207
+ end
208
+ end
209
+
186
210
  def execute_directive_long_timeout(line, content, options)
187
211
  long_timeout, = options
188
212
  invalid_value_p = false
@@ -275,6 +299,8 @@ module Grntest
275
299
  execute_directive_include(line, content, options)
276
300
  when "copy-path"
277
301
  execute_directive_copy_path(line, content, options)
302
+ when "timeout"
303
+ execute_directive_timeout(line, content, options)
278
304
  when "long-timeout"
279
305
  execute_directive_long_timeout(line, content, options)
280
306
  when "on-error"
@@ -373,7 +399,7 @@ module Grntest
373
399
 
374
400
  def read_all_readable_content(output, options={})
375
401
  content = ""
376
- first_timeout = options[:first_timeout] || 5
402
+ first_timeout = options[:first_timeout] || @timeout
377
403
  timeout = first_timeout
378
404
  while IO.select([output], [], [], timeout)
379
405
  break if output.eof?
@@ -458,6 +484,10 @@ module Grntest
458
484
  end
459
485
  end
460
486
 
487
+ def default_timeout
488
+ 3
489
+ end
490
+
461
491
  def default_long_timeout
462
492
  180
463
493
  end
@@ -57,8 +57,6 @@ module Grntest
57
57
  options = {}
58
58
  if may_slow_command?(command)
59
59
  options[:first_timeout] = @long_timeout
60
- elsif command.name == "dump"
61
- options[:first_timeout] = 0.1
62
60
  end
63
61
  read_all_readable_content(@output, options)
64
62
  end
@@ -196,7 +196,7 @@ module Grntest
196
196
  groonga_input = input_write
197
197
  groonga_output = output_read
198
198
 
199
- env = {}
199
+ env = extract_custom_env
200
200
  spawn_options = {}
201
201
  command_line = groonga_command_line(context, spawn_options)
202
202
  if Platform.windows?
@@ -333,13 +333,15 @@ call chdir("#{context.temporary_directory_path}")
333
333
  port = 50041 + @worker.id
334
334
  pid_file_path = context.temporary_directory_path + "groonga.pid"
335
335
 
336
- env = {}
336
+ env = extract_custom_env
337
337
  spawn_options = {}
338
338
  command_line = groonga_http_command(host, port, pid_file_path, context,
339
339
  spawn_options)
340
340
  pid = nil
341
341
  shutdown_wait_timeout = 5
342
- options = {}
342
+ options = {
343
+ :read_timeout => @tester.timeout,
344
+ }
343
345
  if @tester.gdb
344
346
  options[:read_timeout] = 60 * 10
345
347
  end
@@ -451,7 +453,8 @@ events {
451
453
  }
452
454
  GLOBAL
453
455
 
454
- ENV.each do |key, value|
456
+ env = ENV.to_hash.merge(extract_custom_env)
457
+ env.each do |key, value|
455
458
  next unless key.start_with?("GRN_")
456
459
  config_file.puts(<<-ENV)
457
460
  env #{key};
@@ -627,6 +630,21 @@ http {
627
630
  @worker.test_script_path
628
631
  end
629
632
 
633
+ def extract_custom_env
634
+ return {} unless test_script_path.exist?
635
+
636
+ env = {}
637
+ test_script_path.open("r:ascii-8bit") do |script_file|
638
+ script_file.each_line do |line|
639
+ case line
640
+ when /\A\#\$([a-zA-Z_\d]+)=(.*)/
641
+ env[$1] = $2.strip
642
+ end
643
+ end
644
+ end
645
+ env
646
+ end
647
+
630
648
  def have_extension?
631
649
  not test_script_path.extname.empty?
632
650
  end
@@ -14,5 +14,5 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  module Grntest
17
- VERSION = "1.1.6"
17
+ VERSION = "1.1.7"
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grntest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-27 00:00:00.000000000 Z
12
+ date: 2016-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -223,8 +223,8 @@ specification_version: 4
223
223
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
224
224
  by writing Groonga commands and expected result.
225
225
  test_files:
226
- - test/run-test.rb
226
+ - test/test-log-parser.rb
227
227
  - test/executors/test-base-executor.rb
228
228
  - test/executors/test-standard-io-executor.rb
229
- - test/test-log-parser.rb
229
+ - test/run-test.rb
230
230
  has_rdoc: