@owenlamont/ryl 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +13 -0
  2. package/bin/ryl.js +195 -1
  3. package/package.json +35 -13
  4. package/.github/CODEOWNERS +0 -1
  5. package/.github/dependabot.yml +0 -13
  6. package/.github/workflows/ci.yml +0 -107
  7. package/.github/workflows/release.yml +0 -613
  8. package/.github/workflows/update_dependencies.yml +0 -61
  9. package/.github/workflows/update_linters.yml +0 -56
  10. package/.pre-commit-config.yaml +0 -87
  11. package/.yamllint +0 -4
  12. package/AGENTS.md +0 -200
  13. package/Cargo.lock +0 -908
  14. package/Cargo.toml +0 -32
  15. package/clippy.toml +0 -1
  16. package/docs/config-presets.md +0 -100
  17. package/img/benchmark-5x5-5runs.svg +0 -2176
  18. package/pyproject.toml +0 -42
  19. package/ruff.toml +0 -107
  20. package/rumdl.toml +0 -20
  21. package/rust-toolchain.toml +0 -3
  22. package/rustfmt.toml +0 -3
  23. package/scripts/benchmark_perf_vs_yamllint.py +0 -400
  24. package/scripts/coverage-missing.ps1 +0 -80
  25. package/scripts/coverage-missing.sh +0 -60
  26. package/src/bin/discover_config_bin.rs +0 -24
  27. package/src/cli_support.rs +0 -33
  28. package/src/conf/mod.rs +0 -85
  29. package/src/config.rs +0 -2099
  30. package/src/decoder.rs +0 -326
  31. package/src/discover.rs +0 -31
  32. package/src/lib.rs +0 -19
  33. package/src/lint.rs +0 -558
  34. package/src/main.rs +0 -535
  35. package/src/migrate.rs +0 -233
  36. package/src/rules/anchors.rs +0 -517
  37. package/src/rules/braces.rs +0 -77
  38. package/src/rules/brackets.rs +0 -77
  39. package/src/rules/colons.rs +0 -475
  40. package/src/rules/commas.rs +0 -372
  41. package/src/rules/comments.rs +0 -299
  42. package/src/rules/comments_indentation.rs +0 -243
  43. package/src/rules/document_end.rs +0 -175
  44. package/src/rules/document_start.rs +0 -84
  45. package/src/rules/empty_lines.rs +0 -152
  46. package/src/rules/empty_values.rs +0 -255
  47. package/src/rules/float_values.rs +0 -259
  48. package/src/rules/flow_collection.rs +0 -562
  49. package/src/rules/hyphens.rs +0 -104
  50. package/src/rules/indentation.rs +0 -803
  51. package/src/rules/key_duplicates.rs +0 -218
  52. package/src/rules/key_ordering.rs +0 -303
  53. package/src/rules/line_length.rs +0 -326
  54. package/src/rules/mod.rs +0 -25
  55. package/src/rules/new_line_at_end_of_file.rs +0 -23
  56. package/src/rules/new_lines.rs +0 -95
  57. package/src/rules/octal_values.rs +0 -121
  58. package/src/rules/quoted_strings.rs +0 -577
  59. package/src/rules/span_utils.rs +0 -37
  60. package/src/rules/trailing_spaces.rs +0 -65
  61. package/src/rules/truthy.rs +0 -420
  62. package/tests/brackets_carriage_return.rs +0 -114
  63. package/tests/build_global_cfg_error.rs +0 -23
  64. package/tests/cli_anchors_rule.rs +0 -143
  65. package/tests/cli_braces_rule.rs +0 -104
  66. package/tests/cli_brackets_rule.rs +0 -104
  67. package/tests/cli_colons_rule.rs +0 -65
  68. package/tests/cli_commas_rule.rs +0 -104
  69. package/tests/cli_comments_indentation_rule.rs +0 -61
  70. package/tests/cli_comments_rule.rs +0 -67
  71. package/tests/cli_config_data_error.rs +0 -30
  72. package/tests/cli_config_flags.rs +0 -66
  73. package/tests/cli_config_migrate.rs +0 -229
  74. package/tests/cli_document_end_rule.rs +0 -92
  75. package/tests/cli_document_start_rule.rs +0 -92
  76. package/tests/cli_empty_lines_rule.rs +0 -87
  77. package/tests/cli_empty_values_rule.rs +0 -68
  78. package/tests/cli_env_config.rs +0 -34
  79. package/tests/cli_exit_and_errors.rs +0 -41
  80. package/tests/cli_file_encoding.rs +0 -203
  81. package/tests/cli_float_values_rule.rs +0 -64
  82. package/tests/cli_format_options.rs +0 -316
  83. package/tests/cli_global_cfg_relaxed.rs +0 -20
  84. package/tests/cli_hyphens_rule.rs +0 -104
  85. package/tests/cli_indentation_rule.rs +0 -65
  86. package/tests/cli_invalid_project_config.rs +0 -39
  87. package/tests/cli_key_duplicates_rule.rs +0 -104
  88. package/tests/cli_key_ordering_rule.rs +0 -59
  89. package/tests/cli_line_length_rule.rs +0 -85
  90. package/tests/cli_list_files.rs +0 -29
  91. package/tests/cli_new_line_rule.rs +0 -141
  92. package/tests/cli_new_lines_rule.rs +0 -119
  93. package/tests/cli_octal_values_rule.rs +0 -60
  94. package/tests/cli_quoted_strings_rule.rs +0 -47
  95. package/tests/cli_toml_config.rs +0 -119
  96. package/tests/cli_trailing_spaces_rule.rs +0 -77
  97. package/tests/cli_truthy_rule.rs +0 -83
  98. package/tests/cli_yaml_files_negation.rs +0 -45
  99. package/tests/colons_rule.rs +0 -303
  100. package/tests/common/compat.rs +0 -114
  101. package/tests/common/fake_env.rs +0 -93
  102. package/tests/common/mod.rs +0 -1
  103. package/tests/conf_builtin.rs +0 -9
  104. package/tests/config_anchors.rs +0 -84
  105. package/tests/config_braces.rs +0 -121
  106. package/tests/config_brackets.rs +0 -127
  107. package/tests/config_commas.rs +0 -79
  108. package/tests/config_comments.rs +0 -65
  109. package/tests/config_comments_indentation.rs +0 -20
  110. package/tests/config_deep_merge_nonstring_key.rs +0 -24
  111. package/tests/config_document_end.rs +0 -54
  112. package/tests/config_document_start.rs +0 -55
  113. package/tests/config_empty_lines.rs +0 -48
  114. package/tests/config_empty_values.rs +0 -35
  115. package/tests/config_env_errors.rs +0 -23
  116. package/tests/config_env_invalid_inline.rs +0 -15
  117. package/tests/config_env_missing.rs +0 -63
  118. package/tests/config_env_shim.rs +0 -301
  119. package/tests/config_explicit_file_parse_error.rs +0 -55
  120. package/tests/config_extended_features.rs +0 -225
  121. package/tests/config_extends_inline.rs +0 -185
  122. package/tests/config_extends_sequence.rs +0 -18
  123. package/tests/config_find_project_home_boundary.rs +0 -54
  124. package/tests/config_find_project_two_files_in_cwd.rs +0 -47
  125. package/tests/config_float_values.rs +0 -34
  126. package/tests/config_from_yaml_paths.rs +0 -32
  127. package/tests/config_hyphens.rs +0 -51
  128. package/tests/config_ignore_errors.rs +0 -243
  129. package/tests/config_ignore_overrides.rs +0 -83
  130. package/tests/config_indentation.rs +0 -65
  131. package/tests/config_invalid_globs.rs +0 -16
  132. package/tests/config_invalid_types.rs +0 -19
  133. package/tests/config_key_duplicates.rs +0 -34
  134. package/tests/config_key_ordering.rs +0 -70
  135. package/tests/config_line_length.rs +0 -65
  136. package/tests/config_locale.rs +0 -111
  137. package/tests/config_merge.rs +0 -26
  138. package/tests/config_new_lines.rs +0 -89
  139. package/tests/config_octal_values.rs +0 -33
  140. package/tests/config_quoted_strings.rs +0 -195
  141. package/tests/config_rule_level.rs +0 -147
  142. package/tests/config_rules_non_string_keys.rs +0 -23
  143. package/tests/config_scalar_overrides.rs +0 -27
  144. package/tests/config_to_toml.rs +0 -110
  145. package/tests/config_toml_coverage.rs +0 -80
  146. package/tests/config_toml_discovery.rs +0 -304
  147. package/tests/config_trailing_spaces.rs +0 -152
  148. package/tests/config_truthy.rs +0 -77
  149. package/tests/config_yaml_files.rs +0 -62
  150. package/tests/config_yaml_files_all_non_string.rs +0 -15
  151. package/tests/config_yaml_files_empty.rs +0 -30
  152. package/tests/coverage_commas.rs +0 -46
  153. package/tests/decoder_decode.rs +0 -338
  154. package/tests/discover_config_bin_all.rs +0 -66
  155. package/tests/discover_config_bin_env_invalid_yaml.rs +0 -26
  156. package/tests/discover_config_bin_project_config_parse_error.rs +0 -24
  157. package/tests/discover_config_bin_user_global_error.rs +0 -26
  158. package/tests/discover_module.rs +0 -30
  159. package/tests/discover_per_file_dir.rs +0 -10
  160. package/tests/discover_per_file_project_config_error.rs +0 -21
  161. package/tests/float_values.rs +0 -43
  162. package/tests/lint_multi_errors.rs +0 -32
  163. package/tests/main_yaml_ok_filtering.rs +0 -30
  164. package/tests/migrate_module.rs +0 -259
  165. package/tests/resolve_ctx_empty_parent.rs +0 -16
  166. package/tests/rule_anchors.rs +0 -442
  167. package/tests/rule_braces.rs +0 -258
  168. package/tests/rule_brackets.rs +0 -217
  169. package/tests/rule_commas.rs +0 -205
  170. package/tests/rule_comments.rs +0 -197
  171. package/tests/rule_comments_indentation.rs +0 -127
  172. package/tests/rule_document_end.rs +0 -118
  173. package/tests/rule_document_start.rs +0 -60
  174. package/tests/rule_empty_lines.rs +0 -96
  175. package/tests/rule_empty_values.rs +0 -102
  176. package/tests/rule_float_values.rs +0 -109
  177. package/tests/rule_hyphens.rs +0 -65
  178. package/tests/rule_indentation.rs +0 -455
  179. package/tests/rule_key_duplicates.rs +0 -76
  180. package/tests/rule_key_ordering.rs +0 -207
  181. package/tests/rule_line_length.rs +0 -200
  182. package/tests/rule_new_lines.rs +0 -51
  183. package/tests/rule_octal_values.rs +0 -53
  184. package/tests/rule_quoted_strings.rs +0 -290
  185. package/tests/rule_trailing_spaces.rs +0 -41
  186. package/tests/rule_truthy.rs +0 -236
  187. package/tests/user_global_invalid_yaml.rs +0 -32
  188. package/tests/yamllint_compat_anchors.rs +0 -280
  189. package/tests/yamllint_compat_braces.rs +0 -411
  190. package/tests/yamllint_compat_brackets.rs +0 -364
  191. package/tests/yamllint_compat_colons.rs +0 -298
  192. package/tests/yamllint_compat_colors.rs +0 -80
  193. package/tests/yamllint_compat_commas.rs +0 -375
  194. package/tests/yamllint_compat_comments.rs +0 -167
  195. package/tests/yamllint_compat_comments_indentation.rs +0 -281
  196. package/tests/yamllint_compat_config.rs +0 -170
  197. package/tests/yamllint_compat_document_end.rs +0 -243
  198. package/tests/yamllint_compat_document_start.rs +0 -136
  199. package/tests/yamllint_compat_empty_lines.rs +0 -117
  200. package/tests/yamllint_compat_empty_values.rs +0 -179
  201. package/tests/yamllint_compat_float_values.rs +0 -216
  202. package/tests/yamllint_compat_hyphens.rs +0 -223
  203. package/tests/yamllint_compat_indentation.rs +0 -398
  204. package/tests/yamllint_compat_key_duplicates.rs +0 -139
  205. package/tests/yamllint_compat_key_ordering.rs +0 -170
  206. package/tests/yamllint_compat_line_length.rs +0 -375
  207. package/tests/yamllint_compat_list.rs +0 -127
  208. package/tests/yamllint_compat_new_line.rs +0 -133
  209. package/tests/yamllint_compat_newline_types.rs +0 -185
  210. package/tests/yamllint_compat_octal_values.rs +0 -172
  211. package/tests/yamllint_compat_quoted_strings.rs +0 -154
  212. package/tests/yamllint_compat_syntax.rs +0 -200
  213. package/tests/yamllint_compat_trailing_spaces.rs +0 -162
  214. package/tests/yamllint_compat_truthy.rs +0 -130
  215. package/tests/yamllint_compat_yaml_files.rs +0 -81
  216. package/typos.toml +0 -2
@@ -1,80 +0,0 @@
1
- use std::fs;
2
-
3
- use tempfile::tempdir;
4
-
5
- #[path = "common/compat.rs"]
6
- mod compat;
7
-
8
- use compat::{
9
- SCENARIOS, build_ryl_command, build_yamllint_command, capture_with_env,
10
- ensure_yamllint_installed,
11
- };
12
-
13
- struct Case {
14
- label: &'static str,
15
- config_path: Option<std::path::PathBuf>,
16
- expected_exit: i32,
17
- }
18
-
19
- #[test]
20
- fn colored_diagnostics_match_yamllint_across_formats() {
21
- ensure_yamllint_installed();
22
-
23
- let dir = tempdir().unwrap();
24
- let file = dir.path().join("layout.yaml");
25
- fs::write(&file, "list: [1,2]\n").unwrap();
26
-
27
- let warning_cfg = dir.path().join("layout-warning.yml");
28
- fs::write(&warning_cfg, "rules:\n commas:\n level: warning\n").unwrap();
29
-
30
- let cases = [
31
- Case {
32
- label: "default-config",
33
- config_path: None,
34
- expected_exit: 1,
35
- },
36
- Case {
37
- label: "commas-warning",
38
- config_path: Some(warning_cfg.clone()),
39
- expected_exit: 0,
40
- },
41
- ];
42
-
43
- let exe = env!("CARGO_BIN_EXE_ryl");
44
-
45
- for scenario in SCENARIOS {
46
- for case in &cases {
47
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
48
- if let Some(cfg) = &case.config_path {
49
- ryl_cmd.arg("-c").arg(cfg);
50
- }
51
- ryl_cmd.current_dir(dir.path());
52
- ryl_cmd.arg(&file);
53
- let (ryl_code, ryl_output) = capture_with_env(ryl_cmd, scenario.envs);
54
-
55
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
56
- if let Some(cfg) = &case.config_path {
57
- yam_cmd.arg("-c").arg(cfg);
58
- }
59
- yam_cmd.current_dir(dir.path());
60
- yam_cmd.arg(&file);
61
- let (yam_code, yam_output) = capture_with_env(yam_cmd, scenario.envs);
62
-
63
- assert_eq!(
64
- ryl_code, case.expected_exit,
65
- "ryl exit code mismatch (scenario: {}, case: {})",
66
- scenario.label, case.label
67
- );
68
- assert_eq!(
69
- yam_code, case.expected_exit,
70
- "yamllint exit code mismatch (scenario: {}, case: {})",
71
- scenario.label, case.label
72
- );
73
- assert_eq!(
74
- ryl_output, yam_output,
75
- "diagnostic mismatch (scenario: {}, case: {})",
76
- scenario.label, case.label
77
- );
78
- }
79
- }
80
- }
@@ -1,375 +0,0 @@
1
- use std::fs;
2
-
3
- use tempfile::tempdir;
4
-
5
- #[path = "common/compat.rs"]
6
- mod compat;
7
-
8
- use compat::{
9
- SCENARIOS, build_ryl_command, build_yamllint_command, capture_with_env,
10
- ensure_yamllint_installed,
11
- };
12
-
13
- #[test]
14
- fn commas_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let default_cfg = dir.path().join("commas-default.yml");
20
- fs::write(
21
- &default_cfg,
22
- "rules:\n document-start: disable\n commas: enable\n",
23
- )
24
- .unwrap();
25
-
26
- let warning_cfg = dir.path().join("commas-warning.yml");
27
- fs::write(
28
- &warning_cfg,
29
- "rules:\n document-start: disable\n commas:\n level: warning\n",
30
- )
31
- .unwrap();
32
-
33
- let before_cfg = dir.path().join("commas-before.yml");
34
- fs::write(
35
- &before_cfg,
36
- "rules:\n document-start: disable\n commas:\n max-spaces-before: 2\n",
37
- )
38
- .unwrap();
39
-
40
- let after_cfg = dir.path().join("commas-after.yml");
41
- fs::write(
42
- &after_cfg,
43
- "rules:\n document-start: disable\n commas:\n max-spaces-after: 3\n",
44
- )
45
- .unwrap();
46
-
47
- let min_cfg = dir.path().join("commas-min.yml");
48
- fs::write(
49
- &min_cfg,
50
- "rules:\n document-start: disable\n commas:\n min-spaces-after: 2\n max-spaces-after: -1\n",
51
- )
52
- .unwrap();
53
-
54
- let ignore_cfg = dir.path().join("commas-ignore.yml");
55
- fs::write(
56
- &ignore_cfg,
57
- "rules:\n document-start: disable\n commas:\n ignore:\n - ignored.yaml\n",
58
- )
59
- .unwrap();
60
-
61
- let ignore_list = dir.path().join("commas-ignore.txt");
62
- fs::write(&ignore_list, "ignored-from-file.yaml\n").unwrap();
63
-
64
- let ignore_from_file_cfg = dir.path().join("commas-ignore-from-file.yml");
65
- let ignore_path = ignore_list.display().to_string().replace('\'', "''");
66
- fs::write(
67
- &ignore_from_file_cfg,
68
- format!(
69
- "rules:\n document-start: disable\n commas:\n ignore-from-file: '{}'\n",
70
- ignore_path
71
- ),
72
- )
73
- .unwrap();
74
-
75
- let default_violation = dir.path().join("default.yaml");
76
- fs::write(&default_violation, "---\n[1,2]\n").unwrap();
77
-
78
- let before_violation = dir.path().join("before-bad.yaml");
79
- fs::write(&before_violation, "---\n[1 , 2]\n").unwrap();
80
-
81
- let before_ok = dir.path().join("before-ok.yaml");
82
- fs::write(&before_ok, "---\n[1 , 2]\n").unwrap();
83
-
84
- let after_violation = dir.path().join("after-bad.yaml");
85
- fs::write(&after_violation, "---\n[1, 2]\n").unwrap();
86
-
87
- let after_ok = dir.path().join("after-ok.yaml");
88
- fs::write(&after_ok, "---\n[1, 2]\n").unwrap();
89
-
90
- let min_violation = dir.path().join("min-bad.yaml");
91
- fs::write(&min_violation, "---\n[1, 2]\n").unwrap();
92
-
93
- let min_ok = dir.path().join("min-ok.yaml");
94
- fs::write(&min_ok, "---\n[1, 2]\n").unwrap();
95
-
96
- let ignored_file = dir.path().join("ignored.yaml");
97
- fs::write(&ignored_file, "---\n[1,2]\n").unwrap();
98
-
99
- let ignored_from_file = dir.path().join("ignored-from-file.yaml");
100
- fs::write(&ignored_from_file, "---\n[1,2]\n").unwrap();
101
-
102
- let exe = env!("CARGO_BIN_EXE_ryl");
103
-
104
- for scenario in SCENARIOS {
105
- let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
106
- ryl_default
107
- .arg("-c")
108
- .arg(&default_cfg)
109
- .arg(&default_violation);
110
- let (ryl_default_code, ryl_default_output) =
111
- capture_with_env(ryl_default, scenario.envs);
112
-
113
- let mut yam_default = build_yamllint_command(scenario.yam_format);
114
- yam_default
115
- .arg("-c")
116
- .arg(&default_cfg)
117
- .arg(&default_violation);
118
- let (yam_default_code, yam_default_output) =
119
- capture_with_env(yam_default, scenario.envs);
120
-
121
- assert_eq!(ryl_default_code, 1, "ryl default exit ({})", scenario.label);
122
- assert_eq!(
123
- yam_default_code, 1,
124
- "yamllint default exit ({})",
125
- scenario.label
126
- );
127
- assert_eq!(
128
- ryl_default_output, yam_default_output,
129
- "default diagnostics mismatch ({})",
130
- scenario.label
131
- );
132
-
133
- let mut ryl_warning = build_ryl_command(exe, scenario.ryl_format);
134
- ryl_warning
135
- .arg("-c")
136
- .arg(&warning_cfg)
137
- .arg(&default_violation);
138
- let (ryl_warning_code, ryl_warning_output) =
139
- capture_with_env(ryl_warning, scenario.envs);
140
-
141
- let mut yam_warning = build_yamllint_command(scenario.yam_format);
142
- yam_warning
143
- .arg("-c")
144
- .arg(&warning_cfg)
145
- .arg(&default_violation);
146
- let (yam_warning_code, yam_warning_output) =
147
- capture_with_env(yam_warning, scenario.envs);
148
-
149
- assert_eq!(ryl_warning_code, 0, "ryl warning exit ({})", scenario.label);
150
- assert_eq!(
151
- yam_warning_code, 0,
152
- "yamllint warning exit ({})",
153
- scenario.label
154
- );
155
- assert_eq!(
156
- ryl_warning_output, yam_warning_output,
157
- "warning diagnostics mismatch ({})",
158
- scenario.label
159
- );
160
-
161
- let mut ryl_before_bad = build_ryl_command(exe, scenario.ryl_format);
162
- ryl_before_bad
163
- .arg("-c")
164
- .arg(&before_cfg)
165
- .arg(&before_violation);
166
- let (ryl_before_bad_code, ryl_before_bad_output) =
167
- capture_with_env(ryl_before_bad, scenario.envs);
168
-
169
- let mut yam_before_bad = build_yamllint_command(scenario.yam_format);
170
- yam_before_bad
171
- .arg("-c")
172
- .arg(&before_cfg)
173
- .arg(&before_violation);
174
- let (yam_before_bad_code, yam_before_bad_output) =
175
- capture_with_env(yam_before_bad, scenario.envs);
176
-
177
- assert_eq!(
178
- ryl_before_bad_code, 1,
179
- "ryl before-bad exit ({})",
180
- scenario.label
181
- );
182
- assert_eq!(
183
- yam_before_bad_code, 1,
184
- "yamllint before-bad exit ({})",
185
- scenario.label
186
- );
187
- assert_eq!(
188
- ryl_before_bad_output, yam_before_bad_output,
189
- "before-bad diagnostics mismatch ({})",
190
- scenario.label
191
- );
192
-
193
- let mut ryl_before_ok = build_ryl_command(exe, scenario.ryl_format);
194
- ryl_before_ok.arg("-c").arg(&before_cfg).arg(&before_ok);
195
- let (ryl_before_ok_code, ryl_before_ok_output) =
196
- capture_with_env(ryl_before_ok, scenario.envs);
197
-
198
- let mut yam_before_ok = build_yamllint_command(scenario.yam_format);
199
- yam_before_ok.arg("-c").arg(&before_cfg).arg(&before_ok);
200
- let (yam_before_ok_code, yam_before_ok_output) =
201
- capture_with_env(yam_before_ok, scenario.envs);
202
-
203
- assert_eq!(
204
- ryl_before_ok_code, 0,
205
- "ryl before-ok exit ({})",
206
- scenario.label
207
- );
208
- assert_eq!(
209
- yam_before_ok_code, 0,
210
- "yamllint before-ok exit ({})",
211
- scenario.label
212
- );
213
- assert_eq!(
214
- ryl_before_ok_output, yam_before_ok_output,
215
- "before-ok diagnostics mismatch ({})",
216
- scenario.label
217
- );
218
-
219
- let mut ryl_after_bad = build_ryl_command(exe, scenario.ryl_format);
220
- ryl_after_bad
221
- .arg("-c")
222
- .arg(&after_cfg)
223
- .arg(&after_violation);
224
- let (ryl_after_bad_code, ryl_after_bad_output) =
225
- capture_with_env(ryl_after_bad, scenario.envs);
226
-
227
- let mut yam_after_bad = build_yamllint_command(scenario.yam_format);
228
- yam_after_bad
229
- .arg("-c")
230
- .arg(&after_cfg)
231
- .arg(&after_violation);
232
- let (yam_after_bad_code, yam_after_bad_output) =
233
- capture_with_env(yam_after_bad, scenario.envs);
234
-
235
- assert_eq!(
236
- ryl_after_bad_code, 1,
237
- "ryl after-bad exit ({})",
238
- scenario.label
239
- );
240
- assert_eq!(
241
- yam_after_bad_code, 1,
242
- "yamllint after-bad exit ({})",
243
- scenario.label
244
- );
245
- assert_eq!(
246
- ryl_after_bad_output, yam_after_bad_output,
247
- "after-bad diagnostics mismatch ({})",
248
- scenario.label
249
- );
250
-
251
- let mut ryl_after_ok = build_ryl_command(exe, scenario.ryl_format);
252
- ryl_after_ok.arg("-c").arg(&after_cfg).arg(&after_ok);
253
- let (ryl_after_ok_code, ryl_after_ok_output) =
254
- capture_with_env(ryl_after_ok, scenario.envs);
255
-
256
- let mut yam_after_ok = build_yamllint_command(scenario.yam_format);
257
- yam_after_ok.arg("-c").arg(&after_cfg).arg(&after_ok);
258
- let (yam_after_ok_code, yam_after_ok_output) =
259
- capture_with_env(yam_after_ok, scenario.envs);
260
-
261
- assert_eq!(
262
- ryl_after_ok_code, 0,
263
- "ryl after-ok exit ({})",
264
- scenario.label
265
- );
266
- assert_eq!(
267
- yam_after_ok_code, 0,
268
- "yamllint after-ok exit ({})",
269
- scenario.label
270
- );
271
- assert_eq!(
272
- ryl_after_ok_output, yam_after_ok_output,
273
- "after-ok diagnostics mismatch ({})",
274
- scenario.label
275
- );
276
-
277
- let mut ryl_min_bad = build_ryl_command(exe, scenario.ryl_format);
278
- ryl_min_bad.arg("-c").arg(&min_cfg).arg(&min_violation);
279
- let (ryl_min_bad_code, ryl_min_bad_output) =
280
- capture_with_env(ryl_min_bad, scenario.envs);
281
-
282
- let mut yam_min_bad = build_yamllint_command(scenario.yam_format);
283
- yam_min_bad.arg("-c").arg(&min_cfg).arg(&min_violation);
284
- let (yam_min_bad_code, yam_min_bad_output) =
285
- capture_with_env(yam_min_bad, scenario.envs);
286
-
287
- assert_eq!(ryl_min_bad_code, 1, "ryl min-bad exit ({})", scenario.label);
288
- assert_eq!(
289
- yam_min_bad_code, 1,
290
- "yamllint min-bad exit ({})",
291
- scenario.label
292
- );
293
- assert_eq!(
294
- ryl_min_bad_output, yam_min_bad_output,
295
- "min-bad diagnostics mismatch ({})",
296
- scenario.label
297
- );
298
-
299
- let mut ryl_min_ok = build_ryl_command(exe, scenario.ryl_format);
300
- ryl_min_ok.arg("-c").arg(&min_cfg).arg(&min_ok);
301
- let (ryl_min_ok_code, ryl_min_ok_output) =
302
- capture_with_env(ryl_min_ok, scenario.envs);
303
-
304
- let mut yam_min_ok = build_yamllint_command(scenario.yam_format);
305
- yam_min_ok.arg("-c").arg(&min_cfg).arg(&min_ok);
306
- let (yam_min_ok_code, yam_min_ok_output) =
307
- capture_with_env(yam_min_ok, scenario.envs);
308
-
309
- assert_eq!(ryl_min_ok_code, 0, "ryl min-ok exit ({})", scenario.label);
310
- assert_eq!(
311
- yam_min_ok_code, 0,
312
- "yamllint min-ok exit ({})",
313
- scenario.label
314
- );
315
- assert_eq!(
316
- ryl_min_ok_output, yam_min_ok_output,
317
- "min-ok diagnostics mismatch ({})",
318
- scenario.label
319
- );
320
-
321
- let mut ryl_ignore = build_ryl_command(exe, scenario.ryl_format);
322
- ryl_ignore.arg("-c").arg(&ignore_cfg).arg(&ignored_file);
323
- let (ryl_ignore_code, ryl_ignore_output) =
324
- capture_with_env(ryl_ignore, scenario.envs);
325
-
326
- let mut yam_ignore = build_yamllint_command(scenario.yam_format);
327
- yam_ignore.arg("-c").arg(&ignore_cfg).arg(&ignored_file);
328
- let (yam_ignore_code, yam_ignore_output) =
329
- capture_with_env(yam_ignore, scenario.envs);
330
-
331
- assert_eq!(ryl_ignore_code, 0, "ryl ignore exit ({})", scenario.label);
332
- assert_eq!(
333
- yam_ignore_code, 0,
334
- "yamllint ignore exit ({})",
335
- scenario.label
336
- );
337
- assert_eq!(
338
- ryl_ignore_output, yam_ignore_output,
339
- "ignore diagnostics mismatch ({})",
340
- scenario.label
341
- );
342
-
343
- let mut ryl_ignore_file = build_ryl_command(exe, scenario.ryl_format);
344
- ryl_ignore_file
345
- .arg("-c")
346
- .arg(&ignore_from_file_cfg)
347
- .arg(&ignored_from_file);
348
- let (ryl_ignore_file_code, ryl_ignore_file_output) =
349
- capture_with_env(ryl_ignore_file, scenario.envs);
350
-
351
- let mut yam_ignore_file = build_yamllint_command(scenario.yam_format);
352
- yam_ignore_file
353
- .arg("-c")
354
- .arg(&ignore_from_file_cfg)
355
- .arg(&ignored_from_file);
356
- let (yam_ignore_file_code, yam_ignore_file_output) =
357
- capture_with_env(yam_ignore_file, scenario.envs);
358
-
359
- assert_eq!(
360
- ryl_ignore_file_code, 0,
361
- "ryl ignore-from-file exit ({})",
362
- scenario.label
363
- );
364
- assert_eq!(
365
- yam_ignore_file_code, 0,
366
- "yamllint ignore-from-file exit ({})",
367
- scenario.label
368
- );
369
- assert_eq!(
370
- ryl_ignore_file_output, yam_ignore_file_output,
371
- "ignore-from-file diagnostics mismatch ({})",
372
- scenario.label
373
- );
374
- }
375
- }
@@ -1,167 +0,0 @@
1
- use std::fs;
2
-
3
- use tempfile::tempdir;
4
-
5
- #[path = "common/compat.rs"]
6
- mod compat;
7
-
8
- use compat::{
9
- SCENARIOS, build_ryl_command, build_yamllint_command, capture_with_env,
10
- ensure_yamllint_installed,
11
- };
12
-
13
- #[test]
14
- fn comments_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let default_cfg = dir.path().join("comments-default.yml");
20
- fs::write(
21
- &default_cfg,
22
- "rules:\n document-start: disable\n comments:\n require-starting-space: true\n ignore-shebangs: true\n min-spaces-from-content: 2\n",
23
- )
24
- .unwrap();
25
-
26
- let no_require_cfg = dir.path().join("comments-no-require.yml");
27
- fs::write(
28
- &no_require_cfg,
29
- "rules:\n document-start: disable\n comments:\n require-starting-space: false\n ignore-shebangs: true\n min-spaces-from-content: 2\n",
30
- )
31
- .unwrap();
32
-
33
- let shebang_cfg = dir.path().join("comments-shebang.yml");
34
- fs::write(
35
- &shebang_cfg,
36
- "rules:\n document-start: disable\n comments:\n require-starting-space: true\n ignore-shebangs: false\n",
37
- )
38
- .unwrap();
39
-
40
- let bad_file = dir.path().join("bad.yaml");
41
- fs::write(
42
- &bad_file,
43
- "#comment\nkey: value # comment\nvalue: foo #bar\n",
44
- )
45
- .unwrap();
46
-
47
- let inline_file = dir.path().join("inline.yaml");
48
- fs::write(&inline_file, "key: value # comment\n").unwrap();
49
-
50
- let shebang_file = dir.path().join("shebang.yaml");
51
- fs::write(&shebang_file, "#!/usr/bin/env foo\n").unwrap();
52
-
53
- let exe = env!("CARGO_BIN_EXE_ryl");
54
-
55
- for scenario in SCENARIOS {
56
- let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
57
- ryl_default.arg("-c").arg(&default_cfg).arg(&bad_file);
58
- let (ryl_code, ryl_output) = capture_with_env(ryl_default, scenario.envs);
59
-
60
- let mut yam_default = build_yamllint_command(scenario.yam_format);
61
- yam_default.arg("-c").arg(&default_cfg).arg(&bad_file);
62
- let (yam_code, yam_output) = capture_with_env(yam_default, scenario.envs);
63
-
64
- assert_eq!(ryl_code, 1, "ryl default exit ({})", scenario.label);
65
- assert_eq!(yam_code, 1, "yamllint default exit ({})", scenario.label);
66
- assert_eq!(
67
- ryl_output, yam_output,
68
- "default diagnostics mismatch ({})",
69
- scenario.label
70
- );
71
-
72
- let mut ryl_no_require = build_ryl_command(exe, scenario.ryl_format);
73
- ryl_no_require
74
- .arg("-c")
75
- .arg(&no_require_cfg)
76
- .arg(&inline_file);
77
- let (ryl_nr_code, ryl_nr_output) =
78
- capture_with_env(ryl_no_require, scenario.envs);
79
-
80
- let mut yam_no_require = build_yamllint_command(scenario.yam_format);
81
- yam_no_require
82
- .arg("-c")
83
- .arg(&no_require_cfg)
84
- .arg(&inline_file);
85
- let (yam_nr_code, yam_nr_output) =
86
- capture_with_env(yam_no_require, scenario.envs);
87
-
88
- assert_eq!(ryl_nr_code, 1, "ryl no-require exit ({})", scenario.label);
89
- assert_eq!(
90
- yam_nr_code, 1,
91
- "yamllint no-require exit ({})",
92
- scenario.label
93
- );
94
- assert_eq!(
95
- ryl_nr_output, yam_nr_output,
96
- "no-require diagnostics mismatch ({})",
97
- scenario.label
98
- );
99
-
100
- let mut ryl_shebang = build_ryl_command(exe, scenario.ryl_format);
101
- ryl_shebang.arg("-c").arg(&shebang_cfg).arg(&shebang_file);
102
- let (ryl_sh_code, ryl_sh_output) = capture_with_env(ryl_shebang, scenario.envs);
103
-
104
- let mut yam_shebang = build_yamllint_command(scenario.yam_format);
105
- yam_shebang.arg("-c").arg(&shebang_cfg).arg(&shebang_file);
106
- let (yam_sh_code, yam_sh_output) = capture_with_env(yam_shebang, scenario.envs);
107
-
108
- assert_eq!(ryl_sh_code, 1, "ryl shebang exit ({})", scenario.label);
109
- assert_eq!(yam_sh_code, 1, "yamllint shebang exit ({})", scenario.label);
110
- assert_eq!(
111
- ryl_sh_output, yam_sh_output,
112
- "shebang diagnostics mismatch ({})",
113
- scenario.label
114
- );
115
- }
116
- }
117
-
118
- #[test]
119
- fn block_scalar_comments_match_yamllint() {
120
- ensure_yamllint_installed();
121
-
122
- let dir = tempdir().unwrap();
123
-
124
- let cfg_path = dir.path().join("comments.yaml");
125
- fs::write(
126
- &cfg_path,
127
- "rules:\n document-start: disable\n comments:\n min-spaces-from-content: 1\n",
128
- )
129
- .unwrap();
130
-
131
- let yaml_path = dir.path().join("script.yaml");
132
- fs::write(
133
- &yaml_path,
134
- r#"job:
135
- run: |
136
- PREV_VERSION="${{ github.event.inputs.previous_version }}"
137
-
138
- # Remove 'v' prefix if present
139
- PREV_VERSION=${PREV_VERSION#v}
140
- "#,
141
- )
142
- .unwrap();
143
-
144
- let exe = env!("CARGO_BIN_EXE_ryl");
145
-
146
- for scenario in SCENARIOS {
147
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
148
- ryl_cmd.arg("-c").arg(&cfg_path).arg(&yaml_path);
149
- let (ryl_code, ryl_output) = capture_with_env(ryl_cmd, scenario.envs);
150
-
151
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
152
- yam_cmd.arg("-c").arg(&cfg_path).arg(&yaml_path);
153
- let (yam_code, yam_output) = capture_with_env(yam_cmd, scenario.envs);
154
-
155
- assert_eq!(ryl_code, 0, "ryl emitted diagnostics ({})", scenario.label);
156
- assert_eq!(
157
- yam_code, 0,
158
- "yamllint emitted diagnostics ({})",
159
- scenario.label
160
- );
161
- assert_eq!(
162
- ryl_output, yam_output,
163
- "output mismatch ({})",
164
- scenario.label
165
- );
166
- }
167
- }