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.



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/grntest/tester.rb', line 212

def initialize
  @groonga = "groonga"
  @groonga_httpd = "groonga-httpd"
  @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
  @interface = :stdio
  @output_type = "json"
  @testee = "groonga"
  @base_directory = Pathname(".")
  @database_path = nil
  @reporter = nil
  @n_workers = 1
  @output = $stdout
  @keep_database = false
  @use_color = nil
  @test_patterns = []
  @test_suite_patterns = []
  @exclude_test_patterns = []
  @exclude_test_suite_patterns = []
  detect_suitable_diff
  initialize_debuggers
end

Instance Attribute Details

#base_directoryObject

Returns the value of attribute base_directory.



205
206
207
# File 'lib/grntest/tester.rb', line 205

def base_directory
  @base_directory
end

#database_pathObject

Returns the value of attribute database_path.



205
206
207
# File 'lib/grntest/tester.rb', line 205

def database_path
  @database_path
end

#default_gdbObject

Returns the value of attribute default_gdb.



208
209
210
# File 'lib/grntest/tester.rb', line 208

def default_gdb
  @default_gdb
end

#diffObject

Returns the value of attribute diff.



205
206
207
# File 'lib/grntest/tester.rb', line 205

def diff
  @diff
end

#diff_optionsObject

Returns the value of attribute diff_options.



205
206
207
# File 'lib/grntest/tester.rb', line 205

def diff_options
  @diff_options
end

#exclude_test_patternsObject (readonly)

Returns the value of attribute exclude_test_patterns.



211
212
213
# File 'lib/grntest/tester.rb', line 211

def exclude_test_patterns
  @exclude_test_patterns
end

#exclude_test_suite_patternsObject (readonly)

Returns the value of attribute exclude_test_suite_patterns.



211
212
213
# File 'lib/grntest/tester.rb', line 211

def exclude_test_suite_patterns
  @exclude_test_suite_patterns
end

#gdbObject

Returns the value of attribute gdb.



208
209
210
# File 'lib/grntest/tester.rb', line 208

def gdb
  @gdb
end

#groongaObject

Returns the value of attribute groonga.



203
204
205
# File 'lib/grntest/tester.rb', line 203

def groonga
  @groonga
end

#groonga_httpdObject

Returns the value of attribute groonga_httpd.



203
204
205
# File 'lib/grntest/tester.rb', line 203

def groonga_httpd
  @groonga_httpd
end

#groonga_suggest_create_datasetObject

Returns the value of attribute groonga_suggest_create_dataset.



203
204
205
# File 'lib/grntest/tester.rb', line 203

def groonga_suggest_create_dataset
  @groonga_suggest_create_dataset
end

#interfaceObject

Returns the value of attribute interface.



204
205
206
# File 'lib/grntest/tester.rb', line 204

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.



209
210
211
# File 'lib/grntest/tester.rb', line 209

def keep_database=(value)
  @keep_database = value
end

#n_workersObject

Returns the value of attribute n_workers.



206
207
208
# File 'lib/grntest/tester.rb', line 206

def n_workers
  @n_workers
end

#outputObject

Returns the value of attribute output.



207
208
209
# File 'lib/grntest/tester.rb', line 207

def output
  @output
end

#output_typeObject

Returns the value of attribute output_type.



204
205
206
# File 'lib/grntest/tester.rb', line 204

def output_type
  @output_type
end

#reporterObject



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/grntest/tester.rb', line 242

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

#test_patternsObject (readonly)

Returns the value of attribute test_patterns.



210
211
212
# File 'lib/grntest/tester.rb', line 210

def test_patterns
  @test_patterns
end

#test_suite_patternsObject (readonly)

Returns the value of attribute test_suite_patterns.



210
211
212
# File 'lib/grntest/tester.rb', line 210

def test_suite_patterns
  @test_suite_patterns
end

#testeeObject

Returns the value of attribute testee.



204
205
206
# File 'lib/grntest/tester.rb', line 204

def testee
  @testee
end

#use_color=(value) ⇒ Object (writeonly)

Sets the attribute use_color

Parameters:

  • value

    the value to set the attribute use_color to.



209
210
211
# File 'lib/grntest/tester.rb', line 209

def use_color=(value)
  @use_color = value
end

Class Method Details

.run(argv = nil) ⇒ Object



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

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

#excluded_test?(test_name) ⇒ Boolean

Returns:

  • (Boolean)


276
277
278
279
280
# File 'lib/grntest/tester.rb', line 276

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)


294
295
296
297
298
# File 'lib/grntest/tester.rb', line 294

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)


254
255
256
# File 'lib/grntest/tester.rb', line 254

def keep_database?
  @keep_database
end

#run(*targets) ⇒ Object



234
235
236
237
238
239
240
# File 'lib/grntest/tester.rb', line 234

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)


269
270
271
272
273
274
# File 'lib/grntest/tester.rb', line 269

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)


287
288
289
290
291
292
# File 'lib/grntest/tester.rb', line 287

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

#target_test?(test_name) ⇒ Boolean

Returns:

  • (Boolean)


265
266
267
# File 'lib/grntest/tester.rb', line 265

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)


282
283
284
285
# File 'lib/grntest/tester.rb', line 282

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)


258
259
260
261
262
263
# File 'lib/grntest/tester.rb', line 258

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