Class: KnapsackPro::Adapters::BaseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/adapters/base_adapter.rb

Constant Summary collapse

TEST_DIR_PATTERN =

Just example, please overwrite constant in subclass

'test/**{,/*/**}/*_test.rb'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.adapter_bind_method_called_fileObject



9
10
11
12
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 9

def self.adapter_bind_method_called_file
  adapter_name = self.to_s.gsub('::', '-')
  "#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/#{adapter_name}-bind_method_called_for_node_#{KnapsackPro::Config::Env.ci_node_index}.txt"
end

.bindObject



22
23
24
25
26
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 22

def self.bind
  adapter = new
  adapter.bind
  adapter
end

.calculate_slow_id_pathsObject

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 18

def self.calculate_slow_id_paths
  raise NotImplementedError
end

.split_by_test_cases_enabled?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 14

def self.split_by_test_cases_enabled?
  false
end

.verify_bind_method_calledObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 28

def self.verify_bind_method_called
  ::Kernel.at_exit do
    if File.exist?(adapter_bind_method_called_file)
      File.delete(adapter_bind_method_called_file)
    else
      KnapsackPro.logger.error("The `#{self}.bind` method was not called in the test runner configuration. See: #{KnapsackPro::Urls::INSTALLATION_GUIDE}")
      KnapsackPro.logger.error("If `#{self}.bind` was called and you still see this error, ensure the `.knapsack_pro` directory (or its contents) were not removed during the run: #{KnapsackPro::Urls::DASHBOARD__ZEROISH_TEST_EXECUTION_TIMES}")
      Kernel.exit(1)
    end
  end
end

Instance Method Details

#bindObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 40

def bind
  KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
  File.write(self.class.adapter_bind_method_called_file, nil)

  if KnapsackPro::Config::Env.regular_mode?
    KnapsackPro.logger.debug('Regular Mode enabled.')
    bind_time_tracker
    bind_save_report
  end

  if KnapsackPro::Config::Env.queue_mode?
    KnapsackPro.logger.debug('Queue Mode enabled.')
    bind_queue_mode
  end
end

#bind_after_queue_hookObject

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 68

def bind_after_queue_hook
  raise NotImplementedError
end

#bind_before_queue_hookObject

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 64

def bind_before_queue_hook
  raise NotImplementedError
end

#bind_queue_modeObject



72
73
74
75
76
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 72

def bind_queue_mode
  bind_before_queue_hook
  bind_after_queue_hook
  bind_time_tracker
end

#bind_save_reportObject

Raises:

  • (NotImplementedError)


60
61
62
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 60

def bind_save_report
  raise NotImplementedError
end

#bind_time_trackerObject

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/knapsack_pro/adapters/base_adapter.rb', line 56

def bind_time_tracker
  raise NotImplementedError
end