Class: Grntest::Tester

Inherits:
Object
  • Object
show all
Defined in:
lib/grntest/tester.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTester

Returns a new instance of Tester.



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/grntest/tester.rb', line 339

def initialize
  @groonga = "groonga"
  @groonga_httpd = "groonga-httpd"
  @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
  unless command_exist?(@groonga_suggest_create_dataset)
    @groonga_suggest_create_dataset = nil
  end
  @groonga_synonym_generate = "groonga-synonym-generate"
  unless command_exist?(@groonga_synonym_generate)
    @groonga_synonym_generate = nil
  end
  @interface = "stdio"
  @use_http_post = false
  @use_http_chunked = false
  @input_type = "json"
  @output_type = "json"
  @testee = "groonga"
  @base_directory = Pathname(".")
  @database_path = nil
  @reporter = nil
  @n_workers = 1
  @output = $stdout
  @keep_database = false
  @use_color = nil
  @stop_on_failure = false
  @suppress_omit_log = true
  @suppress_backtrace = true
  @debug = false
  @test_patterns = []
  @test_suite_patterns = []
  @exclude_test_patterns = []
  @exclude_test_suite_patterns = []
  detect_suitable_diff
  initialize_debuggers
  initialize_memory_checkers
  @timeout = 5
  @read_timeout = 3
  @n_retries = 0
  @shutdown_wait_timeout = 5
end

Instance Attribute Details

#base_directoryObject

Returns the value of attribute base_directory.



322
323
324
# File 'lib/grntest/tester.rb', line 322

def base_directory
  @base_directory
end

#database_pathObject

Returns the value of attribute database_path.



322
323
324
# File 'lib/grntest/tester.rb', line 322

def database_path
  @database_path
end

#debug=(value) ⇒ Object (writeonly)

Sets the attribute debug

Parameters:

  • value

    the value to set the attribute debug to.



334
335
336
# File 'lib/grntest/tester.rb', line 334

def debug=(value)
  @debug = value
end

#default_gdbObject

Returns the value of attribute default_gdb.



325
326
327
# File 'lib/grntest/tester.rb', line 325

def default_gdb
  @default_gdb
end

#default_valgrindObject

Returns the value of attribute default_valgrind.



326
327
328
# File 'lib/grntest/tester.rb', line 326

def default_valgrind
  @default_valgrind
end

#diffObject

Returns the value of attribute diff.



322
323
324
# File 'lib/grntest/tester.rb', line 322

def diff
  @diff
end

#diff_optionsObject

Returns the value of attribute diff_options.



322
323
324
# File 'lib/grntest/tester.rb', line 322

def diff_options
  @diff_options
end

#exclude_test_patternsObject (readonly)

Returns the value of attribute exclude_test_patterns.



336
337
338
# File 'lib/grntest/tester.rb', line 336

def exclude_test_patterns
  @exclude_test_patterns
end

#exclude_test_suite_patternsObject (readonly)

Returns the value of attribute exclude_test_suite_patterns.



336
337
338
# File 'lib/grntest/tester.rb', line 336

def exclude_test_suite_patterns
  @exclude_test_suite_patterns
end

#gdbObject

Returns the value of attribute gdb.



325
326
327
# File 'lib/grntest/tester.rb', line 325

def gdb
  @gdb
end

#groongaObject

Returns the value of attribute groonga.



312
313
314
# File 'lib/grntest/tester.rb', line 312

def groonga
  @groonga
end

#groonga_httpdObject

Returns the value of attribute groonga_httpd.



313
314
315
# File 'lib/grntest/tester.rb', line 313

def groonga_httpd
  @groonga_httpd
end

#groonga_suggest_create_datasetObject

Returns the value of attribute groonga_suggest_create_dataset.



314
315
316
# File 'lib/grntest/tester.rb', line 314

def groonga_suggest_create_dataset
  @groonga_suggest_create_dataset
end

#groonga_synonym_generateObject

Returns the value of attribute groonga_synonym_generate.



315
316
317
# File 'lib/grntest/tester.rb', line 315

def groonga_synonym_generate
  @groonga_synonym_generate
end

#input_typeObject

Returns the value of attribute input_type.



319
320
321
# File 'lib/grntest/tester.rb', line 319

def input_type
  @input_type
end

#interfaceObject

Returns the value of attribute interface.



316
317
318
# File 'lib/grntest/tester.rb', line 316

def interface
  @interface
end

#keep_database=(value) ⇒ Object (writeonly)

Sets the attribute keep_database

Parameters:

  • value

    the value to set the attribute keep_database to.



330
331
332
# File 'lib/grntest/tester.rb', line 330

def keep_database=(value)
  @keep_database = value
end

#n_retriesObject

Returns the value of attribute n_retries.



337
338
339
# File 'lib/grntest/tester.rb', line 337

def n_retries
  @n_retries
end

#n_workersObject

Returns the value of attribute n_workers.



323
324
325
# File 'lib/grntest/tester.rb', line 323

def n_workers
  @n_workers
end

#outputObject

Returns the value of attribute output.



324
325
326
# File 'lib/grntest/tester.rb', line 324

def output
  @output
end

#output_typeObject

Returns the value of attribute output_type.



320
321
322
# File 'lib/grntest/tester.rb', line 320

def output_type
  @output_type
end

#read_timeoutObject

Returns the value of attribute read_timeout.



328
329
330
# File 'lib/grntest/tester.rb', line 328

def read_timeout
  @read_timeout
end

#reporterObject



388
389
390
391
392
393
394
395
396
397
398
# File 'lib/grntest/tester.rb', line 388

def reporter
  if @reporter.nil?
    if @n_workers == 1
      :mark
    else
      :progress
    end
  else
    @reporter
  end
end

#shutdown_wait_timeoutObject

Returns the value of attribute shutdown_wait_timeout.



338
339
340
# File 'lib/grntest/tester.rb', line 338

def shutdown_wait_timeout
  @shutdown_wait_timeout
end

#stop_on_failure=(value) ⇒ Object (writeonly)

Sets the attribute stop_on_failure

Parameters:

  • value

    the value to set the attribute stop_on_failure to.



331
332
333
# File 'lib/grntest/tester.rb', line 331

def stop_on_failure=(value)
  @stop_on_failure = value
end

#suppress_backtrace=(value) ⇒ Object (writeonly)

Sets the attribute suppress_backtrace

Parameters:

  • value

    the value to set the attribute suppress_backtrace to.



333
334
335
# File 'lib/grntest/tester.rb', line 333

def suppress_backtrace=(value)
  @suppress_backtrace = value
end

#suppress_omit_log=(value) ⇒ Object (writeonly)

Sets the attribute suppress_omit_log

Parameters:

  • value

    the value to set the attribute suppress_omit_log to.



332
333
334
# File 'lib/grntest/tester.rb', line 332

def suppress_omit_log=(value)
  @suppress_omit_log = value
end

#test_patternsObject (readonly)

Returns the value of attribute test_patterns.



335
336
337
# File 'lib/grntest/tester.rb', line 335

def test_patterns
  @test_patterns
end

#test_suite_patternsObject (readonly)

Returns the value of attribute test_suite_patterns.



335
336
337
# File 'lib/grntest/tester.rb', line 335

def test_suite_patterns
  @test_suite_patterns
end

#testeeObject

Returns the value of attribute testee.



321
322
323
# File 'lib/grntest/tester.rb', line 321

def testee
  @testee
end

#timeoutObject

Returns the value of attribute timeout.



327
328
329
# File 'lib/grntest/tester.rb', line 327

def timeout
  @timeout
end

#use_color=(value) ⇒ Object (writeonly)

Sets the attribute use_color

Parameters:

  • value

    the value to set the attribute use_color to.



330
331
332
# File 'lib/grntest/tester.rb', line 330

def use_color=(value)
  @use_color = value
end

#use_http_chunked=(value) ⇒ Object (writeonly)

Sets the attribute use_http_chunked

Parameters:

  • value

    the value to set the attribute use_http_chunked to.



318
319
320
# File 'lib/grntest/tester.rb', line 318

def use_http_chunked=(value)
  @use_http_chunked = value
end

#use_http_post=(value) ⇒ Object (writeonly)

Sets the attribute use_http_post

Parameters:

  • value

    the value to set the attribute use_http_post to.



317
318
319
# File 'lib/grntest/tester.rb', line 317

def use_http_post=(value)
  @use_http_post = value
end

#valgrindObject

Returns the value of attribute valgrind.



326
327
328
# File 'lib/grntest/tester.rb', line 326

def valgrind
  @valgrind
end

#valgrind_gen_suppressions=(value) ⇒ Object (writeonly)

Sets the attribute valgrind_gen_suppressions

Parameters:

  • value

    the value to set the attribute valgrind_gen_suppressions to.



329
330
331
# File 'lib/grntest/tester.rb', line 329

def valgrind_gen_suppressions=(value)
  @valgrind_gen_suppressions = value
end

Class Method Details

.run(argv = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/grntest/tester.rb', line 26

def run(argv=nil)
  argv ||= ARGV.dup
  tester = new
  catch do |tag|
    parser = create_option_parser(tester, tag)
    targets = parser.parse!(argv)
    tester.run(*targets)
  end
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


431
432
433
# File 'lib/grntest/tester.rb', line 431

def debug?
  @debug
end

#excluded_test?(test_name) ⇒ Boolean

Returns:

  • (Boolean)


450
451
452
453
454
# File 'lib/grntest/tester.rb', line 450

def excluded_test?(test_name)
  @exclude_test_patterns.any? do |pattern|
    pattern === test_name
  end
end

#excluded_test_suite?(test_suite_name) ⇒ Boolean

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/grntest/tester.rb', line 468

def excluded_test_suite?(test_suite_name)
  @exclude_test_suite_patterns.any? do |pattern|
    pattern === test_suite_name
  end
end

#keep_database?Boolean

Returns:

  • (Boolean)


408
409
410
# File 'lib/grntest/tester.rb', line 408

def keep_database?
  @keep_database
end

#plugins_directoryObject



474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/grntest/tester.rb', line 474

def plugins_directory
  groonga_path = Pathname(@groonga)
  unless groonga_path.absolute?
    groonga_path = Pathname(resolve_command_path(@groonga)).expand_path
  end
  base_dir = groonga_path.parent.parent
  installed_plugins_dir = base_dir + "lib" + "groonga" + "plugins"
  build_plugins_dir = base_dir + "plugins"
  if installed_plugins_dir.exist?
    installed_plugins_dir
  else
    build_plugins_dir
  end
end

#run(*targets) ⇒ Object



380
381
382
383
384
385
386
# File 'lib/grntest/tester.rb', line 380

def run(*targets)
  succeeded = true
  return succeeded if targets.empty?

  test_suites = load_tests(*targets)
  run_test_suites(test_suites)
end

#selected_test?(test_name) ⇒ Boolean

Returns:

  • (Boolean)


443
444
445
446
447
448
# File 'lib/grntest/tester.rb', line 443

def selected_test?(test_name)
  return true if @test_patterns.empty?
  @test_patterns.any? do |pattern|
    pattern === test_name
  end
end

#selected_test_suite?(test_suite_name) ⇒ Boolean

Returns:

  • (Boolean)


461
462
463
464
465
466
# File 'lib/grntest/tester.rb', line 461

def selected_test_suite?(test_suite_name)
  return true if @test_suite_patterns.empty?
  @test_suite_patterns.any? do |pattern|
    pattern === test_suite_name
  end
end

#stop_on_failure?Boolean

Returns:

  • (Boolean)


419
420
421
# File 'lib/grntest/tester.rb', line 419

def stop_on_failure?
  @stop_on_failure
end

#suppress_backtrace?Boolean

Returns:

  • (Boolean)


427
428
429
# File 'lib/grntest/tester.rb', line 427

def suppress_backtrace?
  @suppress_backtrace
end

#suppress_omit_log?Boolean

Returns:

  • (Boolean)


423
424
425
# File 'lib/grntest/tester.rb', line 423

def suppress_omit_log?
  @suppress_omit_log
end

#target_test?(test_name) ⇒ Boolean

Returns:

  • (Boolean)


439
440
441
# File 'lib/grntest/tester.rb', line 439

def target_test?(test_name)
  selected_test?(test_name) and not excluded_test?(test_name)
end

#target_test_suite?(test_suite_name) ⇒ Boolean

Returns:

  • (Boolean)


456
457
458
459
# File 'lib/grntest/tester.rb', line 456

def target_test_suite?(test_suite_name)
  selected_test_suite?(test_suite_name) and
    not excluded_test_suite?(test_suite_name)
end

#use_color?Boolean

Returns:

  • (Boolean)


412
413
414
415
416
417
# File 'lib/grntest/tester.rb', line 412

def use_color?
  if @use_color.nil?
    @use_color = guess_color_availability
  end
  @use_color
end

#use_http_chunked?Boolean

Returns:

  • (Boolean)


404
405
406
# File 'lib/grntest/tester.rb', line 404

def use_http_chunked?
  @use_http_chunked
end

#use_http_post?Boolean

Returns:

  • (Boolean)


400
401
402
# File 'lib/grntest/tester.rb', line 400

def use_http_post?
  @use_http_post
end

#valgrind_gen_suppressions?Boolean

Returns:

  • (Boolean)


435
436
437
# File 'lib/grntest/tester.rb', line 435

def valgrind_gen_suppressions?
  @valgrind_gen_suppressions
end