@@ -43,23 +43,43 @@ def create_config_content() -> str:
43
43
return yaml .safe_dump (config_content , default_flow_style = False )
44
44
45
45
46
- def create_test_config_content () -> str :
46
+ def create_test_config_content (enable_prebuilt_tests : bool ) -> str :
47
47
"""Generate the content for the test_config.yaml with special content and references."""
48
+
49
+ def format_test_string (test_string : str , comment_char : str ) -> str :
50
+ """Generate a yaml formatted string with a comment character."""
51
+ return f"{ comment_char } - { test_string } "
52
+
53
+ comment_char = "#" if enable_prebuilt_tests else ""
48
54
example_test_config_path = DEFAULT_CONFIG_PATH .parent .joinpath ("example_test_config.yaml" )
49
- content = f"# For more details, refer to the example configuration:\n # { example_test_config_path } \n " \
50
- "# Define tests to explicitly bypass, with all others being run.\n " \
51
- "# To run all tests, set bypass to empty or leave this file commented out.\n \n " \
52
- "unit_tests:\n bypass:\n # - tests.test_all_rules.TestValidRules.test_schema_and_dupes\n " \
53
- "# - tests.test_packages.TestRegistryPackage.test_registry_package_config\n "
54
55
55
- return content
56
+ lines = [
57
+ "# For more details, refer to the example configuration:" ,
58
+ f"# { example_test_config_path } " ,
59
+ "# Define tests to explicitly bypass, with all others being run." ,
60
+ "# To run all tests, set bypass to empty or leave this file commented out." ,
61
+ "" ,
62
+ "unit_tests:" ,
63
+ " bypass:" ,
64
+ format_test_string ("tests.test_gh_workflows.TestWorkflows.test_matrix_to_lock_version_defaults" , comment_char ),
65
+ format_test_string (
66
+ "tests.test_schemas.TestVersionLockSchema.test_version_lock_has_nested_previous" , comment_char
67
+ ),
68
+ format_test_string ("tests.test_packages.TestRegistryPackage.test_registry_package_config" , comment_char ),
69
+ format_test_string ("tests.test_all_rules.TestValidRules.test_schema_and_dupes" , comment_char ),
70
+ ]
71
+
72
+ return "\n " .join (lines )
56
73
57
74
58
75
@custom_rules .command ('setup-config' )
59
76
@click .argument ('directory' , type = Path )
60
77
@click .argument ('kibana-version' , type = str , default = load_etc_dump ('packages.yaml' )['package' ]['name' ])
61
78
@click .option ('--overwrite' , is_flag = True , help = "Overwrite the existing _config.yaml file." )
62
- def setup_config (directory : Path , kibana_version : str , overwrite : bool ):
79
+ @click .option (
80
+ "--enable-prebuilt-tests" , "-e" , is_flag = True , help = "Enable all prebuilt tests instead of default subset."
81
+ )
82
+ def setup_config (directory : Path , kibana_version : str , overwrite : bool , enable_prebuilt_tests : bool ):
63
83
"""Setup the custom rules configuration directory and files with defaults."""
64
84
65
85
config = directory / '_config.yaml'
@@ -111,7 +131,7 @@ def setup_config(directory: Path, kibana_version: str, overwrite: bool):
111
131
package_config .write_text (yaml .safe_dump (package_content , default_flow_style = False ))
112
132
113
133
# Create and configure test_config.yaml
114
- test_config .write_text (create_test_config_content ())
134
+ test_config .write_text (create_test_config_content (enable_prebuilt_tests ))
115
135
116
136
# Create and configure _config.yaml
117
137
config .write_text (create_config_content ())
0 commit comments