grntest 1.5.6 → 1.5.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc70a0713dc6900659018742093257e50ab5569b05e603934d3554939fd0c246
4
- data.tar.gz: 953a77a00a938f5126cc925228195b3dfad9bffc08e2aec83f168acb316cb9c6
3
+ metadata.gz: 2209e3afe2a2ef0d25a9ad8e61e0ef36fad7b9faa7106b20d00511ad6f767a9e
4
+ data.tar.gz: dfe1b6a22dbae8d02ada396dc237e20f7384e94a52b5c37e35d8c2dbd01a90df
5
5
  SHA512:
6
- metadata.gz: 5cc8ec7a63366dd1f0af5e5b414a2f5dd270225eb31905e43712a5c73d049a31b7ecb7e5ed4d61ef124659e660c59c4ae99988b39b5fa5c40b4d8b6fe01db7fe
7
- data.tar.gz: e8ff6acc4e760082c9511a7445baa9662057d12d1cb046b60eafe53277e6310b832198767cbeabd582db6b20fb34bdd9c7e838ccdfc5f9dbf459a138fcd7feef
6
+ metadata.gz: 9e84e6673963cb2bf2de0cb5cbd21a9d64977924716c37102aea48415aab1ffcbfdde2f630030f3179828c9e0855da124ca226523c0a060dd92cfd04bb6880e1
7
+ data.tar.gz: 6f2c4f6730b26200e5fa8d39cb56d550dbe98407e5eb54f824e99f0dac9a84616da12fb1f4a32e799344d443d91fd297128e979a8c1caafa96d85a15fb7444ce
data/doc/text/news.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # News
2
2
 
3
+ ## 1.5.8: 2023-07-21
4
+
5
+ ### Improvements
6
+
7
+ * `--random-seed`: Added.
8
+
9
+ * xml: Accepted negative elapsed time.
10
+
11
+ * Added support for groonga-nginx.
12
+
13
+ ## 1.5.7: 2023-03-08
14
+
15
+ ### Improvements
16
+
17
+ * Added support for `rr`.
18
+
19
+ * Improved backtrace normalization on macOS.
20
+
21
+ * Added `add-substitution` and `remove-substitution` to unify common
22
+ tests for `NormalizerNFKC*`.
23
+
3
24
  ## 1.5.6: 2022-03-16
4
25
 
5
26
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2021 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2023 Sutou Kouhei <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
@@ -47,6 +47,7 @@ module Grntest
47
47
  @sleep_after_command = nil
48
48
  @raw_status_response = nil
49
49
  @features = nil
50
+ @substitutions = {}
50
51
  end
51
52
 
52
53
  def execute(script_path)
@@ -59,6 +60,7 @@ module Grntest
59
60
  parser = create_parser
60
61
  script_file.each_line do |line|
61
62
  begin
63
+ line = substitute_input(line)
62
64
  parser << line
63
65
  rescue Error, Groonga::Command::Parser::Error
64
66
  line_info = "#{script_path}:#{script_file.lineno}:#{line.chomp}"
@@ -319,7 +321,7 @@ module Grntest
319
321
  record << ","
320
322
  end
321
323
  record << "\n"
322
- record << evaluator.evaluate(i).to_json
324
+ record << evaluator.evaluate(i: i).to_json
323
325
  before = Time.now
324
326
  parser << record
325
327
  elapsed = Time.now - before
@@ -479,6 +481,45 @@ module Grntest
479
481
  end
480
482
  end
481
483
 
484
+ def substitute_input(input)
485
+ return input if @substitutions.empty?
486
+ @substitutions.each_value do |pattern, substituted_evaluator, _|
487
+ input = input.gsub(pattern) do
488
+ substituted_evaluator.evaluate(match_data: Regexp.last_match)
489
+ end
490
+ end
491
+ input
492
+ end
493
+
494
+ def normalize_input(input)
495
+ return input if @substitutions.empty?
496
+ @substitutions.each_value do |pattern, _, normalized_evaluator|
497
+ input = input.gsub(pattern) do
498
+ normalized_evaluator.evaluate(match_data: Regexp.last_match)
499
+ end
500
+ end
501
+ input
502
+ end
503
+
504
+ def execute_directive_add_substitution(line, content, options)
505
+ _, pattern, rest = content.split(" ", 3)
506
+ substituted, normalized = Shellwords.shellsplit(rest)
507
+ substituted.force_encoding("UTF-8")
508
+ normalized.force_encoding("UTF-8")
509
+ substituted_evaluator = TemplateEvaluator.new("\"#{substituted}\"")
510
+ normalized_evaluator = TemplateEvaluator.new("\"#{normalized}\"")
511
+ @substitutions[pattern] = [
512
+ compile_pattern(pattern),
513
+ substituted_evaluator,
514
+ normalized_evaluator,
515
+ ]
516
+ end
517
+
518
+ def execute_directive_remove_substitution(line, content, options)
519
+ pattern = content.split(" ", 2)[1]
520
+ @substitutions.delete(pattern)
521
+ end
522
+
482
523
  def execute_directive(parser, line, content)
483
524
  command, *options = Shellwords.split(content)
484
525
  case command
@@ -534,6 +575,10 @@ module Grntest
534
575
  execute_directive_require_feature(line, content, options)
535
576
  when "synonym-generate"
536
577
  execute_directive_synonym_generate(parser, line, content, options)
578
+ when "add-substitution"
579
+ execute_directive_add_substitution(line, content, options)
580
+ when "remove-substitution"
581
+ execute_directive_remove_substitution(line, content, options)
537
582
  else
538
583
  log_input(line)
539
584
  log_error("#|e| unknown directive: <#{command}>")
@@ -722,7 +767,7 @@ module Grntest
722
767
  true
723
768
  when /\A[\w.\\-]+:\d+:\d+: /
724
769
  true
725
- when /\A(?:groonga|groonga-httpd)
770
+ when /\A(?:groonga|groonga-httpd|nginx)
726
771
  \((?:\+0x\h+|\w+\+0x\h+)?\)
727
772
  \s
728
773
  \[0x\h+\]\z/x
@@ -731,7 +776,7 @@ module Grntest
731
776
  # groonga-httpd(+0xbd1aa) [0x564caf2bfc12]
732
777
  # groonga-httpd(ngx_http_core_run_phases+0x25) [0x564caf2bfc12]
733
778
  true
734
- when /\A\d+\s+(?:lib\S+\.dylib|\S+\.so|groonga|nginx|\?\?\?)\s+
779
+ when /\A\d+\s+(?:lib\S+\.dylib|\S+\.so|groonga|nginx|\?\?\?|dyld)\s+
735
780
  0x[\da-f]+\s
736
781
  \S+\s\+\s\d+\z/x
737
782
  true
@@ -780,6 +825,7 @@ module Grntest
780
825
  end
781
826
 
782
827
  def log_input(content)
828
+ content = normalize_input(content)
783
829
  log(:input, content)
784
830
  end
785
831
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2016-2023 Sutou Kouhei <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
@@ -19,8 +19,12 @@ module Grntest
19
19
  @template = template
20
20
  end
21
21
 
22
- def evaluate(i)
23
- eval(@template)
22
+ def evaluate(**local_variables)
23
+ _binding = binding
24
+ local_variables.each do |name, value|
25
+ _binding.local_variable_set(name, value)
26
+ end
27
+ _binding.eval(@template)
24
28
  end
25
29
  end
26
30
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2021 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2022 Sutou Kouhei <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
@@ -272,6 +272,13 @@ call (int)chdir("#{context.temporary_directory_path}")
272
272
  command_line << "--command=#{gdb_command_path}"
273
273
  command_line << "--quiet"
274
274
  command_line << "--args"
275
+ elsif @tester.rr
276
+ if libtool_wrapper?(command)
277
+ command_line << find_libtool(command)
278
+ command_line << "--mode=execute"
279
+ end
280
+ command_line << @tester.rr
281
+ command_line << "record"
275
282
  elsif @tester.valgrind
276
283
  if libtool_wrapper?(command)
277
284
  command_line << find_libtool(command)
@@ -493,10 +500,13 @@ call (int)chdir("#{context.temporary_directory_path}")
493
500
  "-s",
494
501
  context.relative_db_path.to_s,
495
502
  ]
496
- when "groonga-httpd"
497
- command_line = command_command_line(@tester.groonga_httpd, context,
503
+ when "groonga-httpd", "groonga-nginx"
504
+ command_line = command_command_line(@tester.groonga_httpd,
505
+ context,
498
506
  spawn_options)
499
- config_file_path = create_config_file(context, host, port,
507
+ config_file_path = create_config_file(context,
508
+ host,
509
+ port,
500
510
  pid_file_path)
501
511
  command_line += [
502
512
  "-c", config_file_path.to_s,
@@ -510,6 +520,11 @@ call (int)chdir("#{context.temporary_directory_path}")
510
520
  config_file_path =
511
521
  context.temporary_directory_path + "groonga-httpd.conf"
512
522
  config_file_path.open("w") do |config_file|
523
+ if @tester.ngx_http_groonga_module_so
524
+ config_file.puts(<<-LOAD_MODULE)
525
+ load_module #{@tester.ngx_http_groonga_module_so};
526
+ LOAD_MODULE
527
+ end
513
528
  config_file.puts(<<-GLOBAL)
514
529
  daemon off;
515
530
  master_process off;
@@ -718,7 +733,7 @@ http {
718
733
 
719
734
  def normalize_output_xml(content, options)
720
735
  content.sub(/^<RESULT .+?>/) do |result|
721
- result.gsub(/( (?:UP|ELAPSED))="\d+\.\d+(?:e[+-]?\d+)?"/, '\1="0.0"')
736
+ result.gsub(/( (?:UP|ELAPSED))="-?\d+\.\d+(?:e[+-]?\d+)?"/, '\1="0.0"')
722
737
  end
723
738
  end
724
739
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2021 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2023 Sutou Kouhei <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
@@ -38,6 +38,7 @@ module Grntest
38
38
  parser = OptionParser.new
39
39
  parser.banner += " TEST_FILE_OR_DIRECTORY..."
40
40
 
41
+ custom_groonga_httpd = false
41
42
  parser.on("--groonga=COMMAND",
42
43
  "Use COMMAND as groonga command",
43
44
  "(#{tester.groonga})") do |command|
@@ -48,6 +49,13 @@ module Grntest
48
49
  "Use COMMAND as groonga-httpd command for groonga-httpd tests",
49
50
  "(#{tester.groonga_httpd})") do |command|
50
51
  tester.groonga_httpd = normalize_command(command)
52
+ custom_groonga_httpd = true
53
+ end
54
+
55
+ parser.on("--ngx-http-groonga-module-so=PATH",
56
+ "Use PATH as ngx_http_groonga_module.so for groonga-nginx tests",
57
+ "(#{tester.ngx_http_groonga_module_so})") do |path|
58
+ tester.ngx_http_groonga_module_so = path
51
59
  end
52
60
 
53
61
  parser.on("--groonga-suggest-create-dataset=COMMAND",
@@ -101,15 +109,19 @@ module Grntest
101
109
  tester.output_type = type
102
110
  end
103
111
 
104
- available_testees = ["groonga", "groonga-httpd"]
112
+ available_testees = ["groonga", "groonga-httpd", "groonga-nginx"]
105
113
  available_testee_labels = available_testees.join(", ")
106
114
  parser.on("--testee=TESTEE", available_testees,
107
115
  "Test against TESTEE",
108
116
  "[#{available_testee_labels}]",
109
117
  "(#{tester.testee})") do |testee|
110
118
  tester.testee = testee
111
- if tester.testee == "groonga-httpd"
119
+ case tester.testee
120
+ when "groonga-httpd"
112
121
  tester.interface = "http"
122
+ when "groonga-nginx"
123
+ tester.interface = "http"
124
+ tester.groonga_httpd = "nginx" unless custom_groonga_httpd
113
125
  end
114
126
  end
115
127
 
@@ -197,6 +209,12 @@ module Grntest
197
209
  tester.gdb = command || tester.default_gdb
198
210
  end
199
211
 
212
+ parser.on("--rr[=COMMAND]",
213
+ "Run Groonga on 'rr record' and use COMMAND as rr",
214
+ "(#{tester.default_rr})") do |command|
215
+ tester.rr = command || tester.default_rr
216
+ end
217
+
200
218
  parser.on("--valgrind[=COMMAND]",
201
219
  "Run Groonga on valgrind and use COMMAND as valgrind",
202
220
  "(#{tester.default_valgrind})") do |command|
@@ -275,6 +293,11 @@ module Grntest
275
293
  tester.shutdown_wait_timeout = timeout
276
294
  end
277
295
 
296
+ parser.on("--random-seed=SEED", Integer,
297
+ "Seed for random numbers") do |seed|
298
+ srand(seed)
299
+ end
300
+
278
301
  parser.on("--version",
279
302
  "Show version and exit") do
280
303
  puts(VERSION)
@@ -311,6 +334,7 @@ module Grntest
311
334
 
312
335
  attr_accessor :groonga
313
336
  attr_accessor :groonga_httpd
337
+ attr_accessor :ngx_http_groonga_module_so
314
338
  attr_accessor :groonga_suggest_create_dataset
315
339
  attr_accessor :groonga_synonym_generate
316
340
  attr_accessor :interface
@@ -323,6 +347,7 @@ module Grntest
323
347
  attr_accessor :n_workers
324
348
  attr_accessor :output
325
349
  attr_accessor :gdb, :default_gdb
350
+ attr_accessor :rr, :default_rr
326
351
  attr_accessor :valgrind, :default_valgrind
327
352
  attr_accessor :timeout
328
353
  attr_accessor :read_timeout
@@ -339,6 +364,7 @@ module Grntest
339
364
  def initialize
340
365
  @groonga = "groonga"
341
366
  @groonga_httpd = "groonga-httpd"
367
+ @ngx_http_groonga_module_so = nil
342
368
  @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
343
369
  unless command_exist?(@groonga_suggest_create_dataset)
344
370
  @groonga_suggest_create_dataset = nil
@@ -534,6 +560,8 @@ module Grntest
534
560
  def initialize_debuggers
535
561
  @gdb = nil
536
562
  @default_gdb = "gdb"
563
+ @rr = nil
564
+ @default_rr = "rr"
537
565
  end
538
566
 
539
567
  def initialize_memory_checkers
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2022 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2023 Sutou Kouhei <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
@@ -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.5.6"
17
+ VERSION = "1.5.8"
18
18
  end
@@ -93,31 +93,29 @@ module Grntest
93
93
 
94
94
  @result.measure do
95
95
  @reporter.on_worker_start(self)
96
- catch do |tag|
97
- loop do
98
- suite_name, test_script_path, test_name = queue.pop
99
- break if test_script_path.nil?
100
-
101
- unless @suite_name == suite_name
102
- @reporter.on_suite_finish(self) if @suite_name
103
- @suite_name = suite_name
104
- @reporter.on_suite_start(self)
105
- end
106
-
107
- unless run_test(test_script_path, test_name)
108
- succeeded = false
109
- end
110
-
111
- break if interruptted?
112
-
113
- if @tester.stop_on_failure? and @test_suites_result.have_failure?
114
- break
115
- end
96
+ loop do
97
+ suite_name, test_script_path, test_name = queue.pop
98
+ break if test_script_path.nil?
99
+
100
+ unless @suite_name == suite_name
101
+ @reporter.on_suite_finish(self) if @suite_name
102
+ @suite_name = suite_name
103
+ @reporter.on_suite_start(self)
104
+ end
105
+
106
+ unless run_test(test_script_path, test_name)
107
+ succeeded = false
108
+ end
109
+
110
+ break if interruptted?
111
+
112
+ if @tester.stop_on_failure? and @test_suites_result.have_failure?
113
+ break
116
114
  end
117
- @status = "finished"
118
- @reporter.on_suite_finish(@suite_name) if @suite_name
119
- @suite_name = nil
120
115
  end
116
+ @status = "finished"
117
+ @reporter.on_suite_finish(@suite_name) if @suite_name
118
+ @suite_name = nil
121
119
  end
122
120
  @reporter.on_worker_finish(self)
123
121
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grntest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  - Haruka Yoshihara
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-16 00:00:00.000000000 Z
12
+ date: 2023-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: diff-lcs
@@ -269,7 +269,7 @@ homepage: https://github.com/groonga/grntest
269
269
  licenses:
270
270
  - GPL-3.0+
271
271
  metadata: {}
272
- post_install_message:
272
+ post_install_message:
273
273
  rdoc_options: []
274
274
  require_paths:
275
275
  - lib
@@ -284,8 +284,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
286
  requirements: []
287
- rubygems_version: 3.4.0.dev
288
- signing_key:
287
+ rubygems_version: 3.5.0.dev
288
+ signing_key:
289
289
  specification_version: 4
290
290
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
291
291
  by writing Groonga commands and expected result.