grntest 1.2.3 → 1.2.4

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: 1cd44715730b214bd92dd2c6d77b236f3a9d97c4
4
- data.tar.gz: 63dc616b531e5613bf7dfe1ec6c2e6fe04d8fe9c
3
+ metadata.gz: 915bd62815178dc7740a1bf25e0f29483421399e
4
+ data.tar.gz: '02896dee4bbe5117a6fa3acc39c5de14c6243538'
5
5
  SHA512:
6
- metadata.gz: 898f8874c0efb5dc04159ac2224a81688dc88a0c5c081933a5bfb2d8675273f4ff63e27f53dcaa275d68c9b7f6ef16aae226669cd7db49f12ab58ef49a092fe0
7
- data.tar.gz: 955f66d7a2a2333275ded2148ae49d64853a5fe66ccfe55ea3d98ae580ad97116e673b240e062d0d86ba30a9ccafbd062df8ab2cd6f06d152a563eb5030b16e3
6
+ metadata.gz: e93ddd16e4f5397f2a9dd634967234b57459fc848352fb5f2e12730c789676c5ae49909dee17defd181c55998509fa153eb05c1f8ea964129eeeb5f645fff8e0
7
+ data.tar.gz: b79b86bff0a082bc8f949f1041db225cb4b8733d8578675d565e7733bccb9f5a722fbc3f241a7226782149d5f8cfddef6a3ea0e22544685de56ca696b13edd49
data/doc/text/news.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # News
2
2
 
3
+ ## 1.2.4: 2017-03-27
4
+
5
+ ### Improvements
6
+
7
+ * Supported outputting actual file even if the test detects memory
8
+ leaks.
9
+
10
+ * Supported unused port dynamically if static port is unavailable.
11
+
12
+ * Ignored "thread start" log messages.
13
+
14
+ * Supported log with PID.
15
+
16
+ * Supported auto chunked `load`.
17
+
18
+ * Added `--no-suppress-backtrace` option.
19
+
3
20
  ## 1.2.3: 2016-07-19
4
21
 
5
22
  ### Improvements
@@ -24,6 +24,7 @@ module Grntest
24
24
  attr_accessor :abort_tag
25
25
  attr_accessor :timeout
26
26
  attr_accessor :default_timeout
27
+ attr_writer :suppress_backtrace
27
28
  attr_writer :collect_query_log
28
29
  attr_writer :debug
29
30
  def initialize
@@ -42,6 +43,7 @@ module Grntest
42
43
  @timeout = 0
43
44
  @default_timeout = 0
44
45
  @omitted = false
46
+ @suppress_backtrace = true
45
47
  @collect_query_log = false
46
48
  @debug = false
47
49
  end
@@ -50,6 +52,10 @@ module Grntest
50
52
  @logging
51
53
  end
52
54
 
55
+ def suppress_backtrace?
56
+ @suppress_backtrace or debug?
57
+ end
58
+
53
59
  def collect_query_log?
54
60
  @collect_query_log
55
61
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -295,21 +295,23 @@ module Grntest
295
295
  def execute_directive_generate_series(parser, line, content, options)
296
296
  start, stop, table, template, = options
297
297
  evaluator = TemplateEvaluator.new(template)
298
- parser << "load --table #{table}\n"
299
- parser << "["
300
- first_record = true
301
- Integer(start).step(Integer(stop)) do |i|
302
- record = ""
303
- if first_record
304
- first_record = false
305
- else
306
- record << ","
298
+ (Integer(start)..Integer(stop)).each_slice(1000) do |range|
299
+ parser << "load --table #{table}\n"
300
+ parser << "["
301
+ first_record = true
302
+ range.each do |i|
303
+ record = ""
304
+ if first_record
305
+ first_record = false
306
+ else
307
+ record << ","
308
+ end
309
+ record << "\n"
310
+ record << evaluator.evaluate(i).to_json
311
+ parser << record
307
312
  end
308
- record << "\n"
309
- record << evaluator.evaluate(i).to_json
310
- parser << record
313
+ parser << "\n]\n"
311
314
  end
312
- parser << "\n]\n"
313
315
  end
314
316
 
315
317
  def execute_directive(parser, line, content)
@@ -428,7 +430,10 @@ module Grntest
428
430
  parser = LogParser.new
429
431
  parser.parse(log) do |entry|
430
432
  next unless important_log_level?(entry.log_level)
431
- next if backtrace_log_message?(entry.message)
433
+ if @context.suppress_backtrace?
434
+ next if backtrace_log_message?(entry.message)
435
+ end
436
+ next if thread_log_message?(entry.message)
432
437
  important_messages << "\#|#{entry.log_level}| #{entry.message}"
433
438
  end
434
439
  important_messages.join("\n")
@@ -458,7 +463,7 @@ module Grntest
458
463
  case message
459
464
  when /\A\//
460
465
  true
461
- when /\A[a-zA-Z]:\//
466
+ when /\A[a-zA-Z]:[\/\\]/
462
467
  true
463
468
  when /\Agroonga\(\) \[0x[\da-f]+\]\z/
464
469
  true
@@ -471,6 +476,15 @@ module Grntest
471
476
  end
472
477
  end
473
478
 
479
+ def thread_log_message?(message)
480
+ case message
481
+ when /\Athread start/
482
+ true
483
+ else
484
+ false
485
+ end
486
+ end
487
+
474
488
  def error_response?(response, type)
475
489
  status = nil
476
490
  begin
@@ -74,7 +74,7 @@ module Grntest
74
74
  request.content_type = "application/json; charset=UTF-8"
75
75
  request.body = body
76
76
  response = Net::HTTP.start(@host, @port) do |http|
77
- http.read_timeout = @context.timeout
77
+ http.read_timeout = read_timeout
78
78
  http.request(request)
79
79
  end
80
80
  normalize_response_data(command, response.body)
@@ -83,7 +83,7 @@ module Grntest
83
83
  def send_normal_command(command)
84
84
  url = "http://#{@host}:#{@port}#{command.to_uri_format}"
85
85
  begin
86
- open(url, :read_timeout => @context.timeout) do |response|
86
+ open(url, :read_timeout => read_timeout) do |response|
87
87
  normalize_response_data(command, response.read)
88
88
  end
89
89
  rescue SystemCallError
@@ -101,6 +101,14 @@ module Grntest
101
101
  "#{raw_response_data}\n"
102
102
  end
103
103
  end
104
+
105
+ def read_timeout
106
+ if @context.timeout.zero?
107
+ nil
108
+ else
109
+ @context.timeout
110
+ end
111
+ end
104
112
  end
105
113
  end
106
114
  end
@@ -29,12 +29,16 @@ module Grntest
29
29
  end
30
30
  log.each_line do |line|
31
31
  case line
32
- when /\A(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+)\|([a-zA-Z])\|\s*/
32
+ when /\A(\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}\.\d+)\|
33
+ ([a-zA-Z])\|
34
+ (?:\d+:)?
35
+ \s*/x
33
36
  emit_entry.call
34
37
  timestamp = $1
35
38
  log_level = $2
36
39
  message = $POSTMATCH
37
40
  else
41
+ message ||= ""
38
42
  message << line
39
43
  end
40
44
  end
@@ -17,6 +17,7 @@ require "pathname"
17
17
  require "fileutils"
18
18
  require "tempfile"
19
19
  require "timeout"
20
+ require "socket"
20
21
 
21
22
  require "json"
22
23
 
@@ -107,6 +108,7 @@ module Grntest
107
108
  succeeded = false
108
109
  when :leaked
109
110
  @worker.on_test_leak(result)
111
+ output_actual_file(result.actual) unless result.checked?
110
112
  succeeded = false
111
113
  when :omitted
112
114
  @worker.on_test_omission(result)
@@ -139,6 +141,7 @@ module Grntest
139
141
  context.timeout = @tester.timeout
140
142
  context.timeout = 0 if @tester.gdb
141
143
  context.default_timeout = context.timeout
144
+ context.suppress_backtrace = @tester.suppress_backtrace?
142
145
  context.debug = @tester.debug?
143
146
  run_groonga(context) do |executor|
144
147
  executor.execute(test_script_path)
@@ -329,9 +332,27 @@ call chdir("#{context.temporary_directory_path}")
329
332
  "libtool"
330
333
  end
331
334
 
335
+ def decide_groonga_server_port(host)
336
+ static_port = 50041 + @worker.id
337
+ 10.times do
338
+ begin
339
+ TCPSocket.new(host, static_port)
340
+ rescue SystemCallError
341
+ return static_port
342
+ else
343
+ sleep(0.1)
344
+ end
345
+ end
346
+
347
+ dynamic_port = TCPServer.open(host, 0) do |server|
348
+ server.addr[1]
349
+ end
350
+ dynamic_port
351
+ end
352
+
332
353
  def run_groonga_http(context)
333
354
  host = "127.0.0.1"
334
- port = 50041 + @worker.id
355
+ port = decide_groonga_server_port(host)
335
356
  pid_file_path = context.temporary_directory_path + "groonga.pid"
336
357
 
337
358
  env = extract_custom_env(context)
@@ -617,12 +638,17 @@ http {
617
638
  })
618
639
  else
619
640
  error = header["error"]
641
+ normalized_values = {}
620
642
  message = error["message"]
621
- message = normalize_path_in_error_message(message)
643
+ normalized_values["message"] = normalize_error_message(message)
644
+ file = error["file"]
645
+ if file
646
+ normalized_values["file"] = normalize_error_file_path(file)
647
+ end
622
648
  header.merge({
623
649
  "start_time" => 0.0,
624
650
  "elapsed_time" => 0.0,
625
- "error" => error.merge({"message" => message})
651
+ "error" => error.merge(normalized_values),
626
652
  })
627
653
  end
628
654
  else
@@ -633,7 +659,7 @@ http {
633
659
  else
634
660
  message, backtrace = rest
635
661
  _ = backtrace # for suppress warnings
636
- message = normalize_path_in_error_message(message)
662
+ message = normalize_error_message(message)
637
663
  [[return_code, 0.0, 0.0], message]
638
664
  end
639
665
  end
@@ -645,7 +671,7 @@ http {
645
671
  if body["exception"]
646
672
  exception = Marshal.load(Marshal.dump(body["exception"]))
647
673
  message = exception["message"]
648
- exception["message"] = normalize_path_in_error_message(message)
674
+ exception["message"] = normalize_error_message(message)
649
675
  body.merge("exception" => exception)
650
676
  else
651
677
  body.each do |key, value|
@@ -663,11 +689,11 @@ http {
663
689
  end
664
690
 
665
691
  def normalize_error(content)
666
- content = normalize_path_in_error_message(content)
692
+ content = normalize_error_message(content)
667
693
  normalize_raw_content(content)
668
694
  end
669
695
 
670
- def normalize_path_in_error_message(content)
696
+ def normalize_error_message(content)
671
697
  case content
672
698
  when /\A(.*: fopen: failed to open mruby script file: )<(.+?)>?\z/
673
699
  pre = $1
@@ -678,6 +704,10 @@ http {
678
704
  end
679
705
  end
680
706
 
707
+ def normalize_error_file_path(path)
708
+ File.basename(path)
709
+ end
710
+
681
711
  def normalize_plugin_path(path)
682
712
  path.gsub(/\.libs\//, "").gsub(/\.dll\z/, ".so")
683
713
  end
@@ -194,6 +194,12 @@ module Grntest
194
194
  tester.suppress_omit_log = boolean
195
195
  end
196
196
 
197
+ parser.on("--no-suppress-backtrace",
198
+ "Suppress backtrace",
199
+ "(#{tester.suppress_backtrace?})") do |boolean|
200
+ tester.suppress_backtrace = boolean
201
+ end
202
+
197
203
  parser.on("--output=OUTPUT",
198
204
  "Output to OUTPUT",
199
205
  "(stdout)") do |output|
@@ -264,6 +270,7 @@ module Grntest
264
270
  attr_writer :reporter, :keep_database, :use_color
265
271
  attr_writer :stop_on_failure
266
272
  attr_writer :suppress_omit_log
273
+ attr_writer :suppress_backtrace
267
274
  attr_writer :debug
268
275
  attr_reader :test_patterns, :test_suite_patterns
269
276
  attr_reader :exclude_test_patterns, :exclude_test_suite_patterns
@@ -286,6 +293,7 @@ module Grntest
286
293
  @use_color = nil
287
294
  @stop_on_failure = false
288
295
  @suppress_omit_log = true
296
+ @suppress_backtrace = true
289
297
  @debug = false
290
298
  @test_patterns = []
291
299
  @test_suite_patterns = []
@@ -336,6 +344,10 @@ module Grntest
336
344
  @suppress_omit_log
337
345
  end
338
346
 
347
+ def suppress_backtrace?
348
+ @suppress_backtrace
349
+ end
350
+
339
351
  def debug?
340
352
  @debug
341
353
  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.2.3"
17
+ VERSION = "1.2.4"
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.2.3
4
+ version: 1.2.4
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-07-19 00:00:00.000000000 Z
12
+ date: 2017-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -219,14 +219,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  requirements: []
221
221
  rubyforge_project:
222
- rubygems_version: 2.5.1
222
+ rubygems_version: 2.5.2
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
226
226
  by writing Groonga commands and expected result.
227
227
  test_files:
228
- - test/run-test.rb
228
+ - test/test-log-parser.rb
229
229
  - test/executors/test-base-executor.rb
230
230
  - test/executors/test-standard-io-executor.rb
231
- - test/test-log-parser.rb
232
- has_rdoc:
231
+ - test/run-test.rb