Class: Ace::Test::EndToEndRunner::Molecules::TestDiscoverer
- Inherits:
-
Object
- Object
- Ace::Test::EndToEndRunner::Molecules::TestDiscoverer
- Defined in:
- lib/ace/test/end_to_end_runner/molecules/test_discoverer.rb
Overview
Discovers deterministic preflight tests and agent E2E scenarios in packages
Finds test scenarios in the TS-format directory structure:
{package}/test/feat/**/*_test.rb
{package}/test/e2e/TS-*/scenario.yml
Note: This is a Molecule (not an Atom) because it performs filesystem I/O via Dir.glob.
Constant Summary collapse
- TEST_DIRS =
["test/e2e"].freeze
- SCENARIO_FILE =
"scenario.yml"- DEFAULT_PREFLIGHT_GLOBS =
["test/feat/**/*_test.rb"].freeze
- SCENARIO_DIR_PATTERN =
"TS-*"
Instance Method Summary collapse
-
#find_integration_tests(package:, base_dir: Dir.pwd) ⇒ Array<String>
Sorted list of matching deterministic preflight test files.
-
#find_scenarios(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) ⇒ Array<Models::TestScenario>
Find TS-format scenario directories and load them as TestScenario models.
-
#find_tests(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) ⇒ Array<String>
Find E2E test scenario files matching criteria.
-
#list_packages(base_dir: Dir.pwd) ⇒ Array<String>
List all packages that have E2E tests.
Instance Method Details
#find_integration_tests(package:, base_dir: Dir.pwd) ⇒ Array<String>
Returns Sorted list of matching deterministic preflight test files.
53 54 55 56 57 58 59 60 61 |
# File 'lib/ace/test/end_to_end_runner/molecules/test_discoverer.rb', line 53 def find_integration_tests(package:, base_dir: Dir.pwd) package_path = File.join(base_dir, package) preflight_globs.each do |glob| files = Dir.glob(File.join(package_path, glob)).sort return files unless files.empty? end [] end |
#find_scenarios(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) ⇒ Array<Models::TestScenario>
Find TS-format scenario directories and load them as TestScenario models
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ace/test/end_to_end_runner/molecules/test_discoverer.rb', line 71 def find_scenarios(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) patterns = TEST_DIRS.map do |test_dir_name| test_dir = File.join(base_dir, package, test_dir_name) File.join(test_dir, SCENARIO_DIR_PATTERN, SCENARIO_FILE) end scenario_files = Dir.glob(patterns).sort loader = ScenarioLoader.new scenarios = scenario_files.map do |yml_path| scenario_dir = File.dirname(yml_path) loader.load(scenario_dir) end if test_id scenarios = scenarios.select { |s| s.test_id == test_id } end filter_scenarios( scenarios, tags: (), exclude_tags: () ) end |
#find_tests(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) ⇒ Array<String>
Find E2E test scenario files matching criteria
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ace/test/end_to_end_runner/molecules/test_discoverer.rb', line 31 def find_tests(package:, test_id: nil, tags: nil, exclude_tags: nil, base_dir: Dir.pwd) test_ids = test_id ? test_id.split(",").map(&:strip) : [nil] scenario_files = test_ids .flat_map { |id| Dir.glob(build_scenario_pattern(package, id, base_dir)) } .uniq .sort return scenario_files if no_filters?(, ) loader = ScenarioLoader.new scenarios = scenario_files.map do |yml_path| loader.load(File.dirname(yml_path)) end filter_scenarios( scenarios, tags: (), exclude_tags: () ).map(&:file_path).sort end |
#list_packages(base_dir: Dir.pwd) ⇒ Array<String>
List all packages that have E2E tests
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ace/test/end_to_end_runner/molecules/test_discoverer.rb', line 99 def list_packages(base_dir: Dir.pwd) patterns = TEST_DIRS.map do |test_dir_name| File.join(base_dir, "*/#{test_dir_name}/#{SCENARIO_DIR_PATTERN}/#{SCENARIO_FILE}") end base = Pathname.new(base_dir) Dir.glob(patterns) .map { |f| Pathname.new(f).relative_path_from(base).each_filename.first } .uniq .sort end |