Skip to content

Commit be7eeec

Browse files
committed
List matched classes.
1 parent 9dad1be commit be7eeec

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

rails_application/Makefile

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ ifeq ($(origin MUTANT_NODE_INDEX), environment)
2121
echo "Running mutation tests in parallel (Node $$NODE_DISPLAY_INDEX/$(MUTANT_TOTAL_NODES)) for rails_application"; \
2222
echo "--- DEBUG: Checking target directories [$(MUTANT_TARGET_DIRS)] ---"; \
2323
ls -ld $(MUTANT_TARGET_DIRS) || (echo "ERROR: Target directories not found!" && exit 1); \
24-
echo "--- DEBUG: Finding potential subject files ---"; \
24+
\
25+
echo "--- DEBUG: Finding all potential subject files ---"; \
2526
find $(MUTANT_TARGET_DIRS) -name '*.rb' \
2627
-not -path '*/test/*' \
2728
-not -path '*/spec/*' \
@@ -32,60 +33,68 @@ ifeq ($(origin MUTANT_NODE_INDEX), environment)
3233
-print > .all_files.tmp; \
3334
if [ $$? -ne 0 ]; then echo "ERROR: find command failed!"; exit 1; fi; \
3435
FOUND_COUNT=$$(cat .all_files.tmp | wc -l); \
35-
echo "--- DEBUG: Found files count: $$FOUND_COUNT"; \
36-
echo "--- DEBUG: Content of .all_files.tmp (first 5 lines): ---"; \
37-
head -n 5 .all_files.tmp || echo "File .all_files.tmp is empty."; \
38-
echo "--- END DEBUG (find) ---"; \
39-
echo "--- DEBUG: Running awk to create .node_files.tmp ---"; \
40-
awk "NR % $(MUTANT_TOTAL_NODES) == $(MUTANT_NODE_INDEX)" .all_files.tmp > .node_files.tmp; \
41-
if [ $$? -ne 0 ]; then echo "ERROR: awk command failed!"; exit 1; fi; \
42-
NODE_COUNT=$$(cat .node_files.tmp | wc -l); \
43-
echo "--- DEBUG: Files count for this node ($(MUTANT_NODE_INDEX)): $$NODE_COUNT"; \
44-
echo "--- DEBUG: Content of .node_files.tmp (first 5 lines): ---"; \
45-
head -n 5 .node_files.tmp || echo "File .node_files.tmp is empty."; \
46-
echo "--- END DEBUG (awk) ---"; \
47-
echo "--- DEBUG: Attempting to derive subject names for this node... ---"; \
48-
DERIVED_NAMES=$$(cat .node_files.tmp | perl -ne 'next unless /\S/; chomp; s#^(app/(controllers|models|helpers|jobs|mailers|channels|client_panel|read_models|services)|lib)/##; s#\.rb$$##; my @parts = split /\//; my $$result = ""; foreach my $$part (@parts) { next unless $$part; $$part =~ s#_([a-z])#uc($$1)#eg; $$result .= ucfirst($$part) . "::"; } $$result =~ s/::$$//; print "$$result\n" if $$result && $$result !~ /^::/'); \
49-
PERL_EXIT_CODE=$$?; \
50-
if [ $$PERL_EXIT_CODE -ne 0 ]; then \
51-
echo "ERROR: Perl command failed with exit code $$PERL_EXIT_CODE"; \
52-
elif [ -z "$$DERIVED_NAMES" ] && [ "$$NODE_COUNT" -gt 0 ]; then \
53-
echo "WARN: Perl command produced no output, but node files exist."; \
54-
elif [ -z "$$DERIVED_NAMES" ]; then \
55-
echo "Perl command produced no output (expected if no files for node)."; \
36+
echo "--- DEBUG: Total potential files found: $$FOUND_COUNT"; \
37+
echo "--- END DEBUG (find all files) ---"; \
38+
\
39+
echo "--- DEBUG: Deriving all subject names from all found files ---"; \
40+
cat .all_files.tmp | perl -ne 'next unless /\S/; chomp; s#^(app/(controllers|models|helpers|jobs|mailers|channels|client_panel|read_models|services)|lib)/##; s#\.rb$$##; my @parts = split /\//; my $$result = ""; foreach my $$part (@parts) { next unless $$part; $$part =~ s#_([a-z])#uc($$1)#eg; $$result .= ucfirst($$part) . "::"; } $$result =~ s/::$$//; print "$$result\n" if $$result && $$result !~ /^::/' > .all_derived_names.tmp; \
41+
PERL_EXIT_CODE_ALL=$$?; \
42+
if [ $$PERL_EXIT_CODE_ALL -ne 0 ]; then \
43+
echo "ERROR: Perl command for all names failed with exit code $$PERL_EXIT_CODE_ALL"; \
44+
elif [ ! -s .all_derived_names.tmp ] && [ "$$FOUND_COUNT" -gt 0 ]; then \
45+
echo "WARN: Perl command for all names produced no output, but files exist."; \
46+
elif [ ! -s .all_derived_names.tmp ]; then \
47+
echo "Perl command for all names produced no output (expected if no files found)."; \
5648
else \
57-
echo "--- DEBUG: Derived names (before subject filter): ---"; \
58-
echo "$$DERIVED_NAMES" > .derived_names.tmp; \
59-
cat .derived_names.tmp; \
49+
echo "--- DEBUG: All derived names (before subject filter, from .all_derived_names.tmp): ---"; \
50+
head -n 20 .all_derived_names.tmp; \
6051
fi; \
61-
echo "--- END DEBUG (perl) ---"; \
62-
echo "--- DEBUG: Filtering derived names based on .mutant.yml 'subjects' patterns for rails_application ---"; \
52+
echo "--- END DEBUG (perl for all names) ---"; \
53+
\
54+
echo "--- DEBUG: Filtering all derived names based on .mutant.yml 'subjects' patterns ---"; \
6355
SUBJECT_PATTERNS_RAILS_APP='^(Orders::|ClientOrders::)'; \
64-
if [ -f .derived_names.tmp ]; then \
65-
grep -E "$$SUBJECT_PATTERNS_RAILS_APP" .derived_names.tmp > .filtered_names.tmp || true; \
56+
if [ -f .all_derived_names.tmp ]; then \
57+
grep -E "$$SUBJECT_PATTERNS_RAILS_APP" .all_derived_names.tmp > .ci_total_filtered_subjects.tmp || true; \
6658
else \
67-
touch .filtered_names.tmp; \
59+
touch .ci_total_filtered_subjects.tmp; \
6860
fi; \
69-
FILTERED_NAMES_CONTENT=$$(cat .filtered_names.tmp); \
70-
echo "--- DEBUG: Filtered names (after subject filter, from .filtered_names.tmp): ---"; \
71-
echo "$$FILTERED_NAMES_CONTENT"; \
72-
SUBJECT_ARGS=$$(cat .filtered_names.tmp | xargs); \
73-
echo "--- DEBUG: SUBJECT_ARGS for mutant: [$$SUBJECT_ARGS]"; \
61+
CI_TOTAL_FILTERED_COUNT=$$(cat .ci_total_filtered_subjects.tmp | wc -l); \
62+
echo "--- DEBUG: Total filtered subjects for CI count: $$CI_TOTAL_FILTERED_COUNT"; \
63+
echo "--- DEBUG: Total filtered subjects for CI (from .ci_total_filtered_subjects.tmp, first 20 lines): ---"; \
64+
head -n 20 .ci_total_filtered_subjects.tmp || echo "File .ci_total_filtered_subjects.tmp is empty."; \
65+
echo "--- END DEBUG (total CI filtered subjects) ---"; \
66+
\
67+
echo "--- DEBUG: Dividing filtered subjects for this node ($(MUTANT_NODE_INDEX)) ---"; \
68+
awk "NR % $(MUTANT_TOTAL_NODES) == $(MUTANT_NODE_INDEX)" .ci_total_filtered_subjects.tmp > .node_subjects_to_run.tmp; \
69+
if [ $$? -ne 0 ]; then echo "ERROR: awk for node subjects failed!"; exit 1; fi; \
70+
NODE_SUBJECTS_TO_RUN_COUNT=$$(cat .node_subjects_to_run.tmp | wc -l); \
71+
echo "--- DEBUG: Subjects for this node count: $$NODE_SUBJECTS_TO_RUN_COUNT"; \
72+
echo "--- DEBUG: Subjects for this node (from .node_subjects_to_run.tmp, first 10 lines): ---"; \
73+
head -n 10 .node_subjects_to_run.tmp || echo "File .node_subjects_to_run.tmp is empty."; \
74+
echo "--- END DEBUG (node subjects to run) ---"; \
75+
\
76+
SUBJECT_ARGS=$$(cat .node_subjects_to_run.tmp | xargs); \
77+
echo "--- DEBUG: SUBJECT_ARGS for mutant for this node: [$$SUBJECT_ARGS]"; \
78+
\
7479
if [ -z "$$SUBJECT_ARGS" ]; then \
7580
echo "No subjects matching 'subjects' criteria found for this node. Skipping."; \
7681
else \
77-
echo "Attempting to run mutant for filtered subjects: $$SUBJECT_ARGS"; \
82+
echo "Attempting to run mutant for filtered subjects for this node: $$SUBJECT_ARGS"; \
7883
RAILS_ENV=test bundle exec mutant run $$SUBJECT_ARGS; \
7984
MUTANT_EXIT_CODE=$$?; \
8085
if [ $$MUTANT_EXIT_CODE -ne 0 ]; then \
8186
echo "ERROR: mutant run failed with exit code $$MUTANT_EXIT_CODE"; \
8287
exit $$MUTANT_EXIT_CODE; \
8388
fi; \
8489
fi; \
85-
rm -f .all_files.tmp .node_files.tmp .derived_names.tmp .filtered_names.tmp
90+
rm -f .all_files.tmp .all_derived_names.tmp .ci_total_filtered_subjects.tmp .node_subjects_to_run.tmp .node_files_for_derivation.tmp .derived_names_for_node.tmp .filtered_node_subjects.tmp
8691
else
87-
@echo "Running mutation tests locally for rails_application (mutant discovers subjects from .mutant.yml)"
88-
@RAILS_ENV=test bundle exec mutant run
92+
@echo "Running mutation tests locally for rails_application (mutant uses .mutant.yml directly)"
93+
@echo "'--- DEBUG: Total filtered subjects for CI (from .ci_total_filtered_subjects.tmp, first 20 lines): ---'"
94+
@(RAILS_ENV=test bundle exec mutant run); \
95+
MUTANT_LOCAL_EXIT_CODE=$$?; \
96+
echo "Local mutant run finished with exit code: $$MUTANT_LOCAL_EXIT_CODE"; \
97+
exit $$MUTANT_LOCAL_EXIT_CODE
8998
endif
9099

91100
.PHONY: help test db

0 commit comments

Comments
 (0)