Class: Ace::TestRunner::Atoms::TestTypeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/test_runner/atoms/test_type_detector.rb

Overview

Detects whether tests need subprocess isolation based on their content and type

Constant Summary collapse

SUBPROCESS_PATTERNS =

Patterns that indicate a test needs subprocess isolation

[
  /CommandExecutor/,           # Tests that execute shell commands
  /Open3\./,                   # Direct subprocess usage
  /Process\.(spawn|fork|kill)/, # Process manipulation
  /Signal\./,                  # Signal handling
  /system\(/,                  # System command execution
  /`.*`/,                      # Backtick command execution
  /\$\(.*\)/,                  # Command substitution
  /run_in_subprocess/,         # Explicit subprocess test helpers
  /run_in_clean_env/          # Environment isolation helpers
].freeze
ISOLATION_DIRS =

Test directories that typically need isolation

%w[
  integration
  system
  e2e
  end_to_end
].freeze
UNIT_TEST_DIRS =

Test directories that typically don’t need isolation

%w[
  atoms
  molecules
  organisms
  models
  unit
].freeze

Instance Method Summary collapse

Instance Method Details

#needs_subprocess?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ace/test_runner/atoms/test_type_detector.rb', line 38

def needs_subprocess?(file_path)
  # Check if explicitly marked as needing isolation
  return true if isolation_directory?(file_path)

  # Check file content for patterns that require subprocess
  needs_isolation = check_file_content(file_path)
  return true if needs_isolation

  # Unit-directory tests default to in-process only when they do not
  # exercise subprocess-sensitive behavior directly.
  return false if unit_test_directory?(file_path)

  false
end

#test_type(file_path) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ace/test_runner/atoms/test_type_detector.rb', line 53

def test_type(file_path)
  if isolation_directory?(file_path)
    :integration
  elsif check_file_content(file_path)
    :subprocess_required
  elsif unit_test_directory?(file_path)
    :unit
  else
    :unit
  end
end