diff --git a/macros/edr/materializations/test/test.sql b/macros/edr/materializations/test/test.sql index 04897db2d..d22911f0e 100644 --- a/macros/edr/materializations/test/test.sql +++ b/macros/edr/materializations/test/test.sql @@ -14,7 +14,7 @@ {% endmaterialization %} {% macro materialize_test(materialization_macro) %} - {% if not elementary.is_elementary_enabled() %} + {% if not elementary.should_collect_test_results() %} {% do return(materialization_macro()) %} {% endif %} diff --git a/macros/edr/system/configuration/should_collect_test_results.sql b/macros/edr/system/configuration/should_collect_test_results.sql new file mode 100644 index 000000000..953426763 --- /dev/null +++ b/macros/edr/system/configuration/should_collect_test_results.sql @@ -0,0 +1,16 @@ +{% macro should_collect_test_results() %} + {# + Determine if Elementary should collect and cache test results. + We skip collection if: + 1. We are NOT in the execution phase (compilation/parsing). + 2. Elementary infrastructure is not configured. + 3. Test results collection is explicitly disabled via config. + 4. This is an EDR CLI run (initialization is skipped in on_run_start). + #} + {% set is_enabled = elementary.is_elementary_enabled() %} + {% set tests_results_enabled = not elementary.get_config_var('disable_tests_results') %} + {% set edr_cli_run = elementary.get_config_var('edr_cli_run') %} + + {% set should_collect = execute and is_enabled and tests_results_enabled and not edr_cli_run %} + {% do return(should_collect) %} +{% endmacro %}