From bb4fab9192b2dea1495f554f4da8a2afd6a044ee Mon Sep 17 00:00:00 2001 From: Vsevolod Fedorov Date: Thu, 22 Feb 2024 12:52:31 +0300 Subject: [PATCH] Improve macro name in error messages Change-Id: Ib31b7953c22b3fbc23adda889aa3ff980313ec8c --- jenkins_jobs/macro.py | 2 +- .../error_fixtures/macro_error_context_for_builder.error | 2 +- .../error_fixtures/macro_error_context_for_notification.error | 2 +- .../error_fixtures/macro_error_context_for_parameter.error | 2 +- .../error_fixtures/macro_error_context_for_pipeline_scm.error | 2 +- .../error_fixtures/macro_error_context_for_property.error | 2 +- .../error_fixtures/macro_error_context_for_publisher.error | 2 +- .../error_fixtures/macro_error_context_for_reporter.error | 2 +- .../yamlparser/error_fixtures/macro_error_context_for_scm.error | 2 +- .../error_fixtures/macro_error_context_for_trigger.error | 2 +- .../error_fixtures/macro_error_context_for_wrapper.error | 2 +- tests/yamlparser/error_fixtures/macro_with_null_params.error | 2 +- tests/yamlparser/error_fixtures/missing_defaults_at_macro.error | 2 +- .../error_fixtures/missing_param_jinja2_macro_direct.error | 2 +- .../error_fixtures/missing_param_simple_macro_direct.error | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jenkins_jobs/macro.py b/jenkins_jobs/macro.py index aab1d1111..f280fe12f 100644 --- a/jenkins_jobs/macro.py +++ b/jenkins_jobs/macro.py @@ -81,7 +81,7 @@ class Macro(ElementBase): roots.assign(roots.macros[type_name], name, macro, "macro") def __str__(self): - return f"macro {self.name!r}" + return f"{self._type_name} macro {self.name!r}" def dispatch_elements(self, registry, xml_parent, component_data, job_data, params): defaults = self._pick_defaults(self.defaults_name) diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_builder.error b/tests/yamlparser/error_fixtures/macro_error_context_for_builder.error index 7fcd3a06f..cbd3f712c 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_builder.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_builder.error @@ -10,7 +10,7 @@ macro_error_context_for_builder.yaml:8:3: In job template 'sample-job' macro_error_context_for_builder.yaml:11:7: While expanding builder macro call 'sample-builder' - sample-builder: ^ -macro_error_context_for_builder.yaml:3:3: While expanding macro 'sample-builder' +macro_error_context_for_builder.yaml:3:3: While expanding builder macro 'sample-builder' - builder: ^ macro_error_context_for_builder.yaml:6:15: While formatting string 'echo {missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_notification.error b/tests/yamlparser/error_fixtures/macro_error_context_for_notification.error index fd1e38a43..c13df7cfd 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_notification.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_notification.error @@ -10,7 +10,7 @@ macro_error_context_for_notification.yaml:9:3: In job template 'sample-job' macro_error_context_for_notification.yaml:13:7: While expanding notification macro call 'sample-notification' - sample-notification: ^ -macro_error_context_for_notification.yaml:3:3: While expanding macro 'sample-notification' +macro_error_context_for_notification.yaml:3:3: While expanding notification macro 'sample-notification' - notification: ^ macro_error_context_for_notification.yaml:7:15: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_parameter.error b/tests/yamlparser/error_fixtures/macro_error_context_for_parameter.error index 2d7a6f515..855b54c49 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_parameter.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_parameter.error @@ -10,7 +10,7 @@ macro_error_context_for_parameter.yaml:10:3: In job template 'sample-job' macro_error_context_for_parameter.yaml:13:7: While expanding parameter macro call 'sample-parameter' - sample-parameter: ^ -macro_error_context_for_parameter.yaml:3:3: While expanding macro 'sample-parameter' +macro_error_context_for_parameter.yaml:3:3: While expanding parameter macro 'sample-parameter' - parameter: ^ macro_error_context_for_parameter.yaml:8:19: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_pipeline_scm.error b/tests/yamlparser/error_fixtures/macro_error_context_for_pipeline_scm.error index 518ecfc63..f4c164d72 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_pipeline_scm.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_pipeline_scm.error @@ -10,7 +10,7 @@ macro_error_context_for_pipeline_scm.yaml:9:3: In job template 'sample-job' macro_error_context_for_pipeline_scm.yaml:14:9: While expanding scm macro call 'sample-scm' - sample-scm: ^ -macro_error_context_for_pipeline_scm.yaml:3:3: While expanding macro 'sample-scm' +macro_error_context_for_pipeline_scm.yaml:3:3: While expanding scm macro 'sample-scm' - scm: ^ macro_error_context_for_pipeline_scm.yaml:7:15: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_property.error b/tests/yamlparser/error_fixtures/macro_error_context_for_property.error index 37d8f86ec..15ee1fd01 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_property.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_property.error @@ -10,7 +10,7 @@ macro_error_context_for_property.yaml:9:3: In job template 'sample-job' macro_error_context_for_property.yaml:12:7: While expanding property macro call 'sample-property' - sample-property: ^ -macro_error_context_for_property.yaml:3:3: While expanding macro 'sample-property' +macro_error_context_for_property.yaml:3:3: While expanding property macro 'sample-property' - property: ^ macro_error_context_for_property.yaml:7:28: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_publisher.error b/tests/yamlparser/error_fixtures/macro_error_context_for_publisher.error index 28ebf036c..ff9c85250 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_publisher.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_publisher.error @@ -10,7 +10,7 @@ macro_error_context_for_publisher.yaml:9:3: In job template 'sample-job' macro_error_context_for_publisher.yaml:12:7: While expanding publisher macro call 'sample-publisher' - sample-publisher: ^ -macro_error_context_for_publisher.yaml:3:3: While expanding macro 'sample-publisher' +macro_error_context_for_publisher.yaml:3:3: While expanding publisher macro 'sample-publisher' - publisher: ^ macro_error_context_for_publisher.yaml:7:21: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_reporter.error b/tests/yamlparser/error_fixtures/macro_error_context_for_reporter.error index a0ca222d7..cc9f16948 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_reporter.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_reporter.error @@ -10,7 +10,7 @@ macro_error_context_for_reporter.yaml:9:3: In job template 'sample-job' macro_error_context_for_reporter.yaml:13:7: While expanding reporter macro call 'sample-reporter' - sample-reporter: ^ -macro_error_context_for_reporter.yaml:3:3: While expanding macro 'sample-reporter' +macro_error_context_for_reporter.yaml:3:3: While expanding reporter macro 'sample-reporter' - reporter: ^ macro_error_context_for_reporter.yaml:7:21: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_scm.error b/tests/yamlparser/error_fixtures/macro_error_context_for_scm.error index 7085372d6..64c9d50e9 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_scm.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_scm.error @@ -10,7 +10,7 @@ macro_error_context_for_scm.yaml:9:3: In job template 'sample-job' macro_error_context_for_scm.yaml:12:7: While expanding scm macro call 'sample-scm' - sample-scm: ^ -macro_error_context_for_scm.yaml:3:3: While expanding macro 'sample-scm' +macro_error_context_for_scm.yaml:3:3: While expanding scm macro 'sample-scm' - scm: ^ macro_error_context_for_scm.yaml:7:15: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_trigger.error b/tests/yamlparser/error_fixtures/macro_error_context_for_trigger.error index 87c736182..04e11efc9 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_trigger.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_trigger.error @@ -10,7 +10,7 @@ macro_error_context_for_trigger.yaml:9:3: In job template 'sample-job' macro_error_context_for_trigger.yaml:12:7: While expanding trigger macro call 'sample-trigger' - sample-trigger: ^ -macro_error_context_for_trigger.yaml:3:3: While expanding macro 'sample-trigger' +macro_error_context_for_trigger.yaml:3:3: While expanding trigger macro 'sample-trigger' - trigger: ^ macro_error_context_for_trigger.yaml:7:16: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_error_context_for_wrapper.error b/tests/yamlparser/error_fixtures/macro_error_context_for_wrapper.error index 9cc16ed22..3ceb34fee 100644 --- a/tests/yamlparser/error_fixtures/macro_error_context_for_wrapper.error +++ b/tests/yamlparser/error_fixtures/macro_error_context_for_wrapper.error @@ -10,7 +10,7 @@ macro_error_context_for_wrapper.yaml:9:3: In job template 'sample-job' macro_error_context_for_wrapper.yaml:12:7: While expanding wrapper macro call 'sample-wrapper' - sample-wrapper: ^ -macro_error_context_for_wrapper.yaml:3:3: While expanding macro 'sample-wrapper' +macro_error_context_for_wrapper.yaml:3:3: While expanding wrapper macro 'sample-wrapper' - wrapper: ^ macro_error_context_for_wrapper.yaml:7:19: While formatting string '{missing_parameter}': Missing parameter: 'missing_parameter' diff --git a/tests/yamlparser/error_fixtures/macro_with_null_params.error b/tests/yamlparser/error_fixtures/macro_with_null_params.error index a93473c93..7a8669f33 100644 --- a/tests/yamlparser/error_fixtures/macro_with_null_params.error +++ b/tests/yamlparser/error_fixtures/macro_with_null_params.error @@ -10,7 +10,7 @@ macro_with_null_params.yaml:8:3: In job template 'sample-job' macro_with_null_params.yaml:12:9: While expanding builder macro call 'sample-macro' - sample-macro: ^ -macro_with_null_params.yaml:1:3: While expanding macro 'sample-macro' +macro_with_null_params.yaml:1:3: While expanding builder macro 'sample-macro' - builder: ^ macro_with_null_params.yaml:6:17: While formatting string 'echo {hello}': Missing parameter: 'hello' diff --git a/tests/yamlparser/error_fixtures/missing_defaults_at_macro.error b/tests/yamlparser/error_fixtures/missing_defaults_at_macro.error index aa9fd9d0f..c11cb83cb 100644 --- a/tests/yamlparser/error_fixtures/missing_defaults_at_macro.error +++ b/tests/yamlparser/error_fixtures/missing_defaults_at_macro.error @@ -10,6 +10,6 @@ missing_defaults_at_macro.yaml:7:3: In job template 'sample-job' missing_defaults_at_macro.yaml:10:7: While expanding builder macro call 'sample-builder' - sample-builder ^ -missing_defaults_at_macro.yaml:3:15: Macro 'sample-builder' wants defaults 'missing-defaults', but it was never defined +missing_defaults_at_macro.yaml:3:15: Builder macro 'sample-builder' wants defaults 'missing-defaults', but it was never defined defaults: missing-defaults ^ diff --git a/tests/yamlparser/error_fixtures/missing_param_jinja2_macro_direct.error b/tests/yamlparser/error_fixtures/missing_param_jinja2_macro_direct.error index 479f63c0f..c2e5ce184 100644 --- a/tests/yamlparser/error_fixtures/missing_param_jinja2_macro_direct.error +++ b/tests/yamlparser/error_fixtures/missing_param_jinja2_macro_direct.error @@ -10,7 +10,7 @@ missing_param_jinja2_macro_direct.yaml:12:3: In job template 'sample-job' missing_param_jinja2_macro_direct.yaml:15:9: While expanding builder macro call 'sample-builder' - sample-builder: ^ -missing_param_jinja2_macro_direct.yaml:6:3: While expanding macro 'sample-builder' +missing_param_jinja2_macro_direct.yaml:6:3: While expanding builder macro 'sample-builder' - builder: ^ missing_param_jinja2_macro_direct.yaml:9:16: While formatting jinja2 template 'echo {{ missing_param }} {{ other_param ...' diff --git a/tests/yamlparser/error_fixtures/missing_param_simple_macro_direct.error b/tests/yamlparser/error_fixtures/missing_param_simple_macro_direct.error index 33c79d046..f8097e185 100644 --- a/tests/yamlparser/error_fixtures/missing_param_simple_macro_direct.error +++ b/tests/yamlparser/error_fixtures/missing_param_simple_macro_direct.error @@ -10,7 +10,7 @@ missing_param_simple_macro_direct.yaml:12:3: In job template 'sample-job' missing_param_simple_macro_direct.yaml:15:9: While expanding builder macro call 'sample-builder' - sample-builder: ^ -missing_param_simple_macro_direct.yaml:6:3: While expanding macro 'sample-builder' +missing_param_simple_macro_direct.yaml:6:3: While expanding builder macro 'sample-builder' - builder: ^ missing_param_simple_macro_direct.yaml:10:11: While formatting string 'echo {missing_param} {other_param}\n': Missing parameter: 'missing_param'