@owenlamont/ryl 0.4.1
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.
- package/.github/CODEOWNERS +1 -0
- package/.github/dependabot.yml +13 -0
- package/.github/workflows/ci.yml +107 -0
- package/.github/workflows/release.yml +613 -0
- package/.github/workflows/update_dependencies.yml +61 -0
- package/.github/workflows/update_linters.yml +56 -0
- package/.pre-commit-config.yaml +87 -0
- package/.yamllint +4 -0
- package/AGENTS.md +200 -0
- package/Cargo.lock +908 -0
- package/Cargo.toml +32 -0
- package/LICENSE +21 -0
- package/README.md +230 -0
- package/bin/ryl.js +1 -0
- package/clippy.toml +1 -0
- package/docs/config-presets.md +100 -0
- package/img/benchmark-5x5-5runs.svg +2176 -0
- package/package.json +28 -0
- package/pyproject.toml +42 -0
- package/ruff.toml +107 -0
- package/rumdl.toml +20 -0
- package/rust-toolchain.toml +3 -0
- package/rustfmt.toml +3 -0
- package/scripts/benchmark_perf_vs_yamllint.py +400 -0
- package/scripts/coverage-missing.ps1 +80 -0
- package/scripts/coverage-missing.sh +60 -0
- package/src/bin/discover_config_bin.rs +24 -0
- package/src/cli_support.rs +33 -0
- package/src/conf/mod.rs +85 -0
- package/src/config.rs +2099 -0
- package/src/decoder.rs +326 -0
- package/src/discover.rs +31 -0
- package/src/lib.rs +19 -0
- package/src/lint.rs +558 -0
- package/src/main.rs +535 -0
- package/src/migrate.rs +233 -0
- package/src/rules/anchors.rs +517 -0
- package/src/rules/braces.rs +77 -0
- package/src/rules/brackets.rs +77 -0
- package/src/rules/colons.rs +475 -0
- package/src/rules/commas.rs +372 -0
- package/src/rules/comments.rs +299 -0
- package/src/rules/comments_indentation.rs +243 -0
- package/src/rules/document_end.rs +175 -0
- package/src/rules/document_start.rs +84 -0
- package/src/rules/empty_lines.rs +152 -0
- package/src/rules/empty_values.rs +255 -0
- package/src/rules/float_values.rs +259 -0
- package/src/rules/flow_collection.rs +562 -0
- package/src/rules/hyphens.rs +104 -0
- package/src/rules/indentation.rs +803 -0
- package/src/rules/key_duplicates.rs +218 -0
- package/src/rules/key_ordering.rs +303 -0
- package/src/rules/line_length.rs +326 -0
- package/src/rules/mod.rs +25 -0
- package/src/rules/new_line_at_end_of_file.rs +23 -0
- package/src/rules/new_lines.rs +95 -0
- package/src/rules/octal_values.rs +121 -0
- package/src/rules/quoted_strings.rs +577 -0
- package/src/rules/span_utils.rs +37 -0
- package/src/rules/trailing_spaces.rs +65 -0
- package/src/rules/truthy.rs +420 -0
- package/tests/brackets_carriage_return.rs +114 -0
- package/tests/build_global_cfg_error.rs +23 -0
- package/tests/cli_anchors_rule.rs +143 -0
- package/tests/cli_braces_rule.rs +104 -0
- package/tests/cli_brackets_rule.rs +104 -0
- package/tests/cli_colons_rule.rs +65 -0
- package/tests/cli_commas_rule.rs +104 -0
- package/tests/cli_comments_indentation_rule.rs +61 -0
- package/tests/cli_comments_rule.rs +67 -0
- package/tests/cli_config_data_error.rs +30 -0
- package/tests/cli_config_flags.rs +66 -0
- package/tests/cli_config_migrate.rs +229 -0
- package/tests/cli_document_end_rule.rs +92 -0
- package/tests/cli_document_start_rule.rs +92 -0
- package/tests/cli_empty_lines_rule.rs +87 -0
- package/tests/cli_empty_values_rule.rs +68 -0
- package/tests/cli_env_config.rs +34 -0
- package/tests/cli_exit_and_errors.rs +41 -0
- package/tests/cli_file_encoding.rs +203 -0
- package/tests/cli_float_values_rule.rs +64 -0
- package/tests/cli_format_options.rs +316 -0
- package/tests/cli_global_cfg_relaxed.rs +20 -0
- package/tests/cli_hyphens_rule.rs +104 -0
- package/tests/cli_indentation_rule.rs +65 -0
- package/tests/cli_invalid_project_config.rs +39 -0
- package/tests/cli_key_duplicates_rule.rs +104 -0
- package/tests/cli_key_ordering_rule.rs +59 -0
- package/tests/cli_line_length_rule.rs +85 -0
- package/tests/cli_list_files.rs +29 -0
- package/tests/cli_new_line_rule.rs +141 -0
- package/tests/cli_new_lines_rule.rs +119 -0
- package/tests/cli_octal_values_rule.rs +60 -0
- package/tests/cli_quoted_strings_rule.rs +47 -0
- package/tests/cli_toml_config.rs +119 -0
- package/tests/cli_trailing_spaces_rule.rs +77 -0
- package/tests/cli_truthy_rule.rs +83 -0
- package/tests/cli_yaml_files_negation.rs +45 -0
- package/tests/colons_rule.rs +303 -0
- package/tests/common/compat.rs +114 -0
- package/tests/common/fake_env.rs +93 -0
- package/tests/common/mod.rs +1 -0
- package/tests/conf_builtin.rs +9 -0
- package/tests/config_anchors.rs +84 -0
- package/tests/config_braces.rs +121 -0
- package/tests/config_brackets.rs +127 -0
- package/tests/config_commas.rs +79 -0
- package/tests/config_comments.rs +65 -0
- package/tests/config_comments_indentation.rs +20 -0
- package/tests/config_deep_merge_nonstring_key.rs +24 -0
- package/tests/config_document_end.rs +54 -0
- package/tests/config_document_start.rs +55 -0
- package/tests/config_empty_lines.rs +48 -0
- package/tests/config_empty_values.rs +35 -0
- package/tests/config_env_errors.rs +23 -0
- package/tests/config_env_invalid_inline.rs +15 -0
- package/tests/config_env_missing.rs +63 -0
- package/tests/config_env_shim.rs +301 -0
- package/tests/config_explicit_file_parse_error.rs +55 -0
- package/tests/config_extended_features.rs +225 -0
- package/tests/config_extends_inline.rs +185 -0
- package/tests/config_extends_sequence.rs +18 -0
- package/tests/config_find_project_home_boundary.rs +54 -0
- package/tests/config_find_project_two_files_in_cwd.rs +47 -0
- package/tests/config_float_values.rs +34 -0
- package/tests/config_from_yaml_paths.rs +32 -0
- package/tests/config_hyphens.rs +51 -0
- package/tests/config_ignore_errors.rs +243 -0
- package/tests/config_ignore_overrides.rs +83 -0
- package/tests/config_indentation.rs +65 -0
- package/tests/config_invalid_globs.rs +16 -0
- package/tests/config_invalid_types.rs +19 -0
- package/tests/config_key_duplicates.rs +34 -0
- package/tests/config_key_ordering.rs +70 -0
- package/tests/config_line_length.rs +65 -0
- package/tests/config_locale.rs +111 -0
- package/tests/config_merge.rs +26 -0
- package/tests/config_new_lines.rs +89 -0
- package/tests/config_octal_values.rs +33 -0
- package/tests/config_quoted_strings.rs +195 -0
- package/tests/config_rule_level.rs +147 -0
- package/tests/config_rules_non_string_keys.rs +23 -0
- package/tests/config_scalar_overrides.rs +27 -0
- package/tests/config_to_toml.rs +110 -0
- package/tests/config_toml_coverage.rs +80 -0
- package/tests/config_toml_discovery.rs +304 -0
- package/tests/config_trailing_spaces.rs +152 -0
- package/tests/config_truthy.rs +77 -0
- package/tests/config_yaml_files.rs +62 -0
- package/tests/config_yaml_files_all_non_string.rs +15 -0
- package/tests/config_yaml_files_empty.rs +30 -0
- package/tests/coverage_commas.rs +46 -0
- package/tests/decoder_decode.rs +338 -0
- package/tests/discover_config_bin_all.rs +66 -0
- package/tests/discover_config_bin_env_invalid_yaml.rs +26 -0
- package/tests/discover_config_bin_project_config_parse_error.rs +24 -0
- package/tests/discover_config_bin_user_global_error.rs +26 -0
- package/tests/discover_module.rs +30 -0
- package/tests/discover_per_file_dir.rs +10 -0
- package/tests/discover_per_file_project_config_error.rs +21 -0
- package/tests/float_values.rs +43 -0
- package/tests/lint_multi_errors.rs +32 -0
- package/tests/main_yaml_ok_filtering.rs +30 -0
- package/tests/migrate_module.rs +259 -0
- package/tests/resolve_ctx_empty_parent.rs +16 -0
- package/tests/rule_anchors.rs +442 -0
- package/tests/rule_braces.rs +258 -0
- package/tests/rule_brackets.rs +217 -0
- package/tests/rule_commas.rs +205 -0
- package/tests/rule_comments.rs +197 -0
- package/tests/rule_comments_indentation.rs +127 -0
- package/tests/rule_document_end.rs +118 -0
- package/tests/rule_document_start.rs +60 -0
- package/tests/rule_empty_lines.rs +96 -0
- package/tests/rule_empty_values.rs +102 -0
- package/tests/rule_float_values.rs +109 -0
- package/tests/rule_hyphens.rs +65 -0
- package/tests/rule_indentation.rs +455 -0
- package/tests/rule_key_duplicates.rs +76 -0
- package/tests/rule_key_ordering.rs +207 -0
- package/tests/rule_line_length.rs +200 -0
- package/tests/rule_new_lines.rs +51 -0
- package/tests/rule_octal_values.rs +53 -0
- package/tests/rule_quoted_strings.rs +290 -0
- package/tests/rule_trailing_spaces.rs +41 -0
- package/tests/rule_truthy.rs +236 -0
- package/tests/user_global_invalid_yaml.rs +32 -0
- package/tests/yamllint_compat_anchors.rs +280 -0
- package/tests/yamllint_compat_braces.rs +411 -0
- package/tests/yamllint_compat_brackets.rs +364 -0
- package/tests/yamllint_compat_colons.rs +298 -0
- package/tests/yamllint_compat_colors.rs +80 -0
- package/tests/yamllint_compat_commas.rs +375 -0
- package/tests/yamllint_compat_comments.rs +167 -0
- package/tests/yamllint_compat_comments_indentation.rs +281 -0
- package/tests/yamllint_compat_config.rs +170 -0
- package/tests/yamllint_compat_document_end.rs +243 -0
- package/tests/yamllint_compat_document_start.rs +136 -0
- package/tests/yamllint_compat_empty_lines.rs +117 -0
- package/tests/yamllint_compat_empty_values.rs +179 -0
- package/tests/yamllint_compat_float_values.rs +216 -0
- package/tests/yamllint_compat_hyphens.rs +223 -0
- package/tests/yamllint_compat_indentation.rs +398 -0
- package/tests/yamllint_compat_key_duplicates.rs +139 -0
- package/tests/yamllint_compat_key_ordering.rs +170 -0
- package/tests/yamllint_compat_line_length.rs +375 -0
- package/tests/yamllint_compat_list.rs +127 -0
- package/tests/yamllint_compat_new_line.rs +133 -0
- package/tests/yamllint_compat_newline_types.rs +185 -0
- package/tests/yamllint_compat_octal_values.rs +172 -0
- package/tests/yamllint_compat_quoted_strings.rs +154 -0
- package/tests/yamllint_compat_syntax.rs +200 -0
- package/tests/yamllint_compat_trailing_spaces.rs +162 -0
- package/tests/yamllint_compat_truthy.rs +130 -0
- package/tests/yamllint_compat_yaml_files.rs +81 -0
- package/typos.toml +2 -0
|
@@ -0,0 +1,281 @@
|
|
|
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_indentation_rule_matches_yamllint() {
|
|
15
|
+
ensure_yamllint_installed();
|
|
16
|
+
|
|
17
|
+
let dir = tempdir().unwrap();
|
|
18
|
+
|
|
19
|
+
let enable_cfg = dir.path().join("comments-enable.yml");
|
|
20
|
+
fs::write(
|
|
21
|
+
&enable_cfg,
|
|
22
|
+
"rules:\n document-start: disable\n comments-indentation: enable\n",
|
|
23
|
+
)
|
|
24
|
+
.unwrap();
|
|
25
|
+
|
|
26
|
+
let warning_cfg = dir.path().join("comments-warning.yml");
|
|
27
|
+
fs::write(
|
|
28
|
+
&warning_cfg,
|
|
29
|
+
"rules:\n document-start: disable\n comments-indentation:\n level: warning\n",
|
|
30
|
+
)
|
|
31
|
+
.unwrap();
|
|
32
|
+
|
|
33
|
+
let ignore_cfg = dir.path().join("comments-ignore.yml");
|
|
34
|
+
fs::write(
|
|
35
|
+
&ignore_cfg,
|
|
36
|
+
"rules:\n document-start: disable\n comments-indentation:\n ignore:\n - ignored.yaml\n",
|
|
37
|
+
)
|
|
38
|
+
.unwrap();
|
|
39
|
+
|
|
40
|
+
let ignore_list = dir.path().join("comments-ignore.txt");
|
|
41
|
+
fs::write(&ignore_list, "ignored-from-file.yaml\n").unwrap();
|
|
42
|
+
|
|
43
|
+
let ignore_from_file_cfg = dir.path().join("comments-ignore-from-file.yml");
|
|
44
|
+
let ignore_path = ignore_list.display().to_string().replace('\'', "''");
|
|
45
|
+
fs::write(
|
|
46
|
+
&ignore_from_file_cfg,
|
|
47
|
+
format!(
|
|
48
|
+
"rules:\n document-start: disable\n comments-indentation:\n ignore-from-file: '{}'\n",
|
|
49
|
+
ignore_path
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
.unwrap();
|
|
53
|
+
|
|
54
|
+
let bad_file = dir.path().join("bad.yaml");
|
|
55
|
+
fs::write(&bad_file, "obj:\n # wrong\n value: 1\n").unwrap();
|
|
56
|
+
|
|
57
|
+
let ignored_file = dir.path().join("ignored.yaml");
|
|
58
|
+
fs::write(&ignored_file, "obj:\n # wrong\n value: 1\n").unwrap();
|
|
59
|
+
|
|
60
|
+
let ignored_from_file = dir.path().join("ignored-from-file.yaml");
|
|
61
|
+
fs::write(&ignored_from_file, "obj:\n # wrong\n value: 1\n").unwrap();
|
|
62
|
+
|
|
63
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
64
|
+
|
|
65
|
+
for scenario in SCENARIOS {
|
|
66
|
+
let mut ryl_enable = build_ryl_command(exe, scenario.ryl_format);
|
|
67
|
+
ryl_enable.arg("-c").arg(&enable_cfg).arg(&bad_file);
|
|
68
|
+
let (ryl_code, ryl_output) = capture_with_env(ryl_enable, scenario.envs);
|
|
69
|
+
|
|
70
|
+
let mut yam_enable = build_yamllint_command(scenario.yam_format);
|
|
71
|
+
yam_enable.arg("-c").arg(&enable_cfg).arg(&bad_file);
|
|
72
|
+
let (yam_code, yam_output) = capture_with_env(yam_enable, scenario.envs);
|
|
73
|
+
|
|
74
|
+
assert_eq!(ryl_code, 1, "ryl enable exit ({})", scenario.label);
|
|
75
|
+
assert_eq!(yam_code, 1, "yamllint enable exit ({})", scenario.label);
|
|
76
|
+
assert_eq!(
|
|
77
|
+
ryl_output, yam_output,
|
|
78
|
+
"enable diagnostics mismatch ({})",
|
|
79
|
+
scenario.label
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
let mut ryl_warning = build_ryl_command(exe, scenario.ryl_format);
|
|
83
|
+
ryl_warning.arg("-c").arg(&warning_cfg).arg(&bad_file);
|
|
84
|
+
let (ryl_warn_code, ryl_warn_output) =
|
|
85
|
+
capture_with_env(ryl_warning, scenario.envs);
|
|
86
|
+
|
|
87
|
+
let mut yam_warning = build_yamllint_command(scenario.yam_format);
|
|
88
|
+
yam_warning.arg("-c").arg(&warning_cfg).arg(&bad_file);
|
|
89
|
+
let (yam_warn_code, yam_warn_output) =
|
|
90
|
+
capture_with_env(yam_warning, scenario.envs);
|
|
91
|
+
|
|
92
|
+
assert_eq!(ryl_warn_code, 0, "ryl warning exit ({})", scenario.label);
|
|
93
|
+
assert_eq!(
|
|
94
|
+
yam_warn_code, 0,
|
|
95
|
+
"yamllint warning exit ({})",
|
|
96
|
+
scenario.label
|
|
97
|
+
);
|
|
98
|
+
assert_eq!(
|
|
99
|
+
ryl_warn_output, yam_warn_output,
|
|
100
|
+
"warning diagnostics mismatch ({})",
|
|
101
|
+
scenario.label
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
let mut ryl_ignore = build_ryl_command(exe, scenario.ryl_format);
|
|
105
|
+
ryl_ignore.arg("-c").arg(&ignore_cfg).arg(&ignored_file);
|
|
106
|
+
let (ryl_ignore_code, ryl_ignore_output) =
|
|
107
|
+
capture_with_env(ryl_ignore, scenario.envs);
|
|
108
|
+
|
|
109
|
+
let mut yam_ignore = build_yamllint_command(scenario.yam_format);
|
|
110
|
+
yam_ignore.arg("-c").arg(&ignore_cfg).arg(&ignored_file);
|
|
111
|
+
let (yam_ignore_code, yam_ignore_output) =
|
|
112
|
+
capture_with_env(yam_ignore, scenario.envs);
|
|
113
|
+
|
|
114
|
+
assert_eq!(ryl_ignore_code, 0, "ryl ignore exit ({})", scenario.label);
|
|
115
|
+
assert_eq!(
|
|
116
|
+
yam_ignore_code, 0,
|
|
117
|
+
"yamllint ignore exit ({})",
|
|
118
|
+
scenario.label
|
|
119
|
+
);
|
|
120
|
+
assert_eq!(
|
|
121
|
+
ryl_ignore_output, yam_ignore_output,
|
|
122
|
+
"ignore diagnostics mismatch ({})",
|
|
123
|
+
scenario.label
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
let mut ryl_ignore_file = build_ryl_command(exe, scenario.ryl_format);
|
|
127
|
+
ryl_ignore_file
|
|
128
|
+
.arg("-c")
|
|
129
|
+
.arg(&ignore_from_file_cfg)
|
|
130
|
+
.arg(&ignored_from_file);
|
|
131
|
+
let (ryl_file_code, ryl_file_output) =
|
|
132
|
+
capture_with_env(ryl_ignore_file, scenario.envs);
|
|
133
|
+
|
|
134
|
+
let mut yam_ignore_file = build_yamllint_command(scenario.yam_format);
|
|
135
|
+
yam_ignore_file
|
|
136
|
+
.arg("-c")
|
|
137
|
+
.arg(&ignore_from_file_cfg)
|
|
138
|
+
.arg(&ignored_from_file);
|
|
139
|
+
let (yam_file_code, yam_file_output) =
|
|
140
|
+
capture_with_env(yam_ignore_file, scenario.envs);
|
|
141
|
+
|
|
142
|
+
assert_eq!(
|
|
143
|
+
ryl_file_code, 0,
|
|
144
|
+
"ryl ignore-from-file exit ({})",
|
|
145
|
+
scenario.label
|
|
146
|
+
);
|
|
147
|
+
assert_eq!(
|
|
148
|
+
yam_file_code, 0,
|
|
149
|
+
"yamllint ignore-from-file exit ({})",
|
|
150
|
+
scenario.label
|
|
151
|
+
);
|
|
152
|
+
assert_eq!(
|
|
153
|
+
ryl_file_output, yam_file_output,
|
|
154
|
+
"ignore-from-file diagnostics mismatch ({})",
|
|
155
|
+
scenario.label
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#[test]
|
|
161
|
+
fn comments_around_line_length_toggle_match_yamllint() {
|
|
162
|
+
ensure_yamllint_installed();
|
|
163
|
+
|
|
164
|
+
let dir = tempdir().unwrap();
|
|
165
|
+
let cfg = dir.path().join("cfg.yml");
|
|
166
|
+
fs::write(
|
|
167
|
+
&cfg,
|
|
168
|
+
"extends: default\nrules:\n line-length:\n max: 110\n",
|
|
169
|
+
)
|
|
170
|
+
.unwrap();
|
|
171
|
+
|
|
172
|
+
let input = dir.path().join("input.yml");
|
|
173
|
+
fs::write(
|
|
174
|
+
&input,
|
|
175
|
+
"body:\n - type: markdown\n attributes:\n # yamllint disable rule:line-length\n value: |\n hello\n # yamllint enable rule:line-length\n",
|
|
176
|
+
)
|
|
177
|
+
.unwrap();
|
|
178
|
+
|
|
179
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
180
|
+
|
|
181
|
+
for scenario in SCENARIOS {
|
|
182
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
183
|
+
ryl_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
184
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
185
|
+
|
|
186
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
187
|
+
yam_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
188
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
189
|
+
|
|
190
|
+
assert_eq!(
|
|
191
|
+
ryl_code, yam_code,
|
|
192
|
+
"exit mismatch for comments around line-length toggle ({})",
|
|
193
|
+
scenario.label
|
|
194
|
+
);
|
|
195
|
+
assert_eq!(
|
|
196
|
+
ryl_msg, yam_msg,
|
|
197
|
+
"diagnostics mismatch for comments around line-length toggle ({})",
|
|
198
|
+
scenario.label
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#[test]
|
|
204
|
+
fn comment_after_block_scalar_pattern_matches_yamllint() {
|
|
205
|
+
ensure_yamllint_installed();
|
|
206
|
+
|
|
207
|
+
let dir = tempdir().unwrap();
|
|
208
|
+
let cfg = dir.path().join("cfg.yml");
|
|
209
|
+
fs::write(
|
|
210
|
+
&cfg,
|
|
211
|
+
"extends: default\nrules:\n line-length:\n max: 110\n",
|
|
212
|
+
)
|
|
213
|
+
.unwrap();
|
|
214
|
+
|
|
215
|
+
let input = dir.path().join("input.yml");
|
|
216
|
+
fs::write(
|
|
217
|
+
&input,
|
|
218
|
+
"---\nhooks:\n - id: x\n files: >\n (?x)\n ^a$|\n ^b$\n ## ONLY ADD PREK HOOKS HERE THAT REQUIRE CI IMAGE\n - id: y\n",
|
|
219
|
+
)
|
|
220
|
+
.unwrap();
|
|
221
|
+
|
|
222
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
223
|
+
for scenario in SCENARIOS {
|
|
224
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
225
|
+
ryl_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
|
|
226
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
227
|
+
|
|
228
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
229
|
+
yam_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
|
|
230
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
231
|
+
|
|
232
|
+
assert_eq!(
|
|
233
|
+
ryl_code, yam_code,
|
|
234
|
+
"exit mismatch for comment after block scalar pattern ({})",
|
|
235
|
+
scenario.label
|
|
236
|
+
);
|
|
237
|
+
assert_eq!(
|
|
238
|
+
ryl_msg, yam_msg,
|
|
239
|
+
"diagnostics mismatch for comment after block scalar pattern ({})",
|
|
240
|
+
scenario.label
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
#[test]
|
|
246
|
+
fn explicit_key_block_scalar_comment_content_matches_yamllint() {
|
|
247
|
+
ensure_yamllint_installed();
|
|
248
|
+
|
|
249
|
+
let dir = tempdir().unwrap();
|
|
250
|
+
let cfg = dir.path().join("cfg.yml");
|
|
251
|
+
fs::write(
|
|
252
|
+
&cfg,
|
|
253
|
+
"rules:\n document-start: disable\n comments-indentation: enable\n",
|
|
254
|
+
)
|
|
255
|
+
.unwrap();
|
|
256
|
+
|
|
257
|
+
let input = dir.path().join("input.yml");
|
|
258
|
+
fs::write(&input, "? |\n # block scalar content\n: value\n").unwrap();
|
|
259
|
+
|
|
260
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
261
|
+
for scenario in SCENARIOS {
|
|
262
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
263
|
+
ryl_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
264
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
265
|
+
|
|
266
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
267
|
+
yam_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
268
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
269
|
+
|
|
270
|
+
assert_eq!(
|
|
271
|
+
ryl_code, yam_code,
|
|
272
|
+
"exit mismatch for explicit-key block scalar comment content ({})",
|
|
273
|
+
scenario.label
|
|
274
|
+
);
|
|
275
|
+
assert_eq!(
|
|
276
|
+
ryl_msg, yam_msg,
|
|
277
|
+
"diagnostics mismatch for explicit-key block scalar comment content ({})",
|
|
278
|
+
scenario.label
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::process::Command;
|
|
3
|
+
|
|
4
|
+
use tempfile::tempdir;
|
|
5
|
+
|
|
6
|
+
fn ensure_yamllint_installed() {
|
|
7
|
+
let ok = Command::new("yamllint")
|
|
8
|
+
.arg("--version")
|
|
9
|
+
.output()
|
|
10
|
+
.map(|o| o.status.success())
|
|
11
|
+
.unwrap_or(false);
|
|
12
|
+
assert!(
|
|
13
|
+
ok,
|
|
14
|
+
"yamllint must be installed and in PATH for parity tests"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fn run(cmd: &mut Command) -> (i32, String, String) {
|
|
19
|
+
let out = cmd.output().expect("failed to run command");
|
|
20
|
+
let code = out.status.code().unwrap_or(-1);
|
|
21
|
+
let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
|
|
22
|
+
let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
|
|
23
|
+
(code, stdout, stderr)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#[test]
|
|
27
|
+
fn yamllint_and_ryl_honor_ignore_from_file() {
|
|
28
|
+
ensure_yamllint_installed();
|
|
29
|
+
|
|
30
|
+
let td = tempdir().unwrap();
|
|
31
|
+
let root = td.path();
|
|
32
|
+
fs::write(
|
|
33
|
+
root.join(".yamllint"),
|
|
34
|
+
"ignore-from-file: patterns.ignore\nrules: {}\n",
|
|
35
|
+
)
|
|
36
|
+
.unwrap();
|
|
37
|
+
fs::write(root.join("patterns.ignore"), "*.skip.yaml\n").unwrap();
|
|
38
|
+
fs::write(root.join("keep.yaml"), "ok: 1\n").unwrap();
|
|
39
|
+
fs::write(root.join("skip.yaml"), "bad: [1\n").unwrap();
|
|
40
|
+
|
|
41
|
+
let ryl = env!("CARGO_BIN_EXE_ryl");
|
|
42
|
+
let (_code, ryl_out, ryl_err) = run(Command::new(ryl)
|
|
43
|
+
.current_dir(root)
|
|
44
|
+
.arg("--list-files")
|
|
45
|
+
.arg("."));
|
|
46
|
+
assert!(ryl_err.is_empty(), "unexpected stderr from ryl: {ryl_err}");
|
|
47
|
+
let mut ryl_list: Vec<_> = ryl_out.lines().map(|s| s.to_string()).collect();
|
|
48
|
+
ryl_list.sort();
|
|
49
|
+
|
|
50
|
+
let (_yc, y_out, y_err) = run(Command::new("yamllint")
|
|
51
|
+
.current_dir(root)
|
|
52
|
+
.arg("--list-files")
|
|
53
|
+
.arg("."));
|
|
54
|
+
assert!(y_err.is_empty(), "unexpected stderr from yamllint: {y_err}");
|
|
55
|
+
let mut y_list: Vec<_> = y_out.lines().map(|s| s.to_string()).collect();
|
|
56
|
+
y_list.sort();
|
|
57
|
+
|
|
58
|
+
assert_eq!(ryl_list, y_list, "file lists should match");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[test]
|
|
62
|
+
fn project_config_precedence_over_env_matches_yamllint() {
|
|
63
|
+
ensure_yamllint_installed();
|
|
64
|
+
|
|
65
|
+
let td = tempdir().unwrap();
|
|
66
|
+
let root = td.path();
|
|
67
|
+
fs::write(
|
|
68
|
+
root.join(".yamllint"),
|
|
69
|
+
"ignore: ['ignored.yaml']\nrules: {}\n",
|
|
70
|
+
)
|
|
71
|
+
.unwrap();
|
|
72
|
+
let env_cfg = root.join("env.yaml");
|
|
73
|
+
fs::write(&env_cfg, "rules: {}\n").unwrap();
|
|
74
|
+
fs::write(root.join("ignored.yaml"), "ok: 1\n").unwrap();
|
|
75
|
+
fs::write(root.join("keep.yaml"), "ok: 1\n").unwrap();
|
|
76
|
+
|
|
77
|
+
let ryl = env!("CARGO_BIN_EXE_ryl");
|
|
78
|
+
let (_code, ryl_out, ryl_err) = run(Command::new(ryl)
|
|
79
|
+
.current_dir(root)
|
|
80
|
+
.env("YAMLLINT_CONFIG_FILE", env_cfg.display().to_string())
|
|
81
|
+
.arg("--list-files")
|
|
82
|
+
.arg("."));
|
|
83
|
+
assert!(ryl_err.is_empty(), "unexpected stderr from ryl: {ryl_err}");
|
|
84
|
+
let mut ryl_list: Vec<_> = ryl_out.lines().map(|s| s.to_string()).collect();
|
|
85
|
+
ryl_list.sort();
|
|
86
|
+
|
|
87
|
+
let (_yc, y_out, y_err) = run(Command::new("yamllint")
|
|
88
|
+
.current_dir(root)
|
|
89
|
+
.env("YAMLLINT_CONFIG_FILE", env_cfg.display().to_string())
|
|
90
|
+
.arg("--list-files")
|
|
91
|
+
.arg("."));
|
|
92
|
+
assert!(y_err.is_empty(), "unexpected stderr from yamllint: {y_err}");
|
|
93
|
+
let mut y_list: Vec<_> = y_out.lines().map(|s| s.to_string()).collect();
|
|
94
|
+
y_list.sort();
|
|
95
|
+
|
|
96
|
+
assert_eq!(ryl_list, y_list, "project config should take precedence");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#[test]
|
|
100
|
+
fn ignore_can_reinclude_file_from_excluded_directory_matches_yamllint() {
|
|
101
|
+
ensure_yamllint_installed();
|
|
102
|
+
|
|
103
|
+
let td = tempdir().unwrap();
|
|
104
|
+
let root = td.path();
|
|
105
|
+
fs::write(
|
|
106
|
+
root.join(".yamllint"),
|
|
107
|
+
"ignore: |\n build/\n !build/keep.yaml\nrules: {}\n",
|
|
108
|
+
)
|
|
109
|
+
.unwrap();
|
|
110
|
+
fs::create_dir_all(root.join("build")).unwrap();
|
|
111
|
+
fs::write(root.join("build/keep.yaml"), "ok: 1\n").unwrap();
|
|
112
|
+
fs::write(root.join("build/drop.yaml"), "ok: 1\n").unwrap();
|
|
113
|
+
fs::write(root.join("top.yaml"), "ok: 1\n").unwrap();
|
|
114
|
+
|
|
115
|
+
let ryl = env!("CARGO_BIN_EXE_ryl");
|
|
116
|
+
let (_code, ryl_out, ryl_err) = run(Command::new(ryl)
|
|
117
|
+
.current_dir(root)
|
|
118
|
+
.arg("--list-files")
|
|
119
|
+
.arg("."));
|
|
120
|
+
assert!(ryl_err.is_empty(), "unexpected stderr from ryl: {ryl_err}");
|
|
121
|
+
let mut ryl_list: Vec<_> = ryl_out.lines().map(|s| s.to_string()).collect();
|
|
122
|
+
ryl_list.sort();
|
|
123
|
+
|
|
124
|
+
let (_yc, y_out, y_err) = run(Command::new("yamllint")
|
|
125
|
+
.current_dir(root)
|
|
126
|
+
.arg("--list-files")
|
|
127
|
+
.arg("."));
|
|
128
|
+
assert!(y_err.is_empty(), "unexpected stderr from yamllint: {y_err}");
|
|
129
|
+
let mut y_list: Vec<_> = y_out.lines().map(|s| s.to_string()).collect();
|
|
130
|
+
y_list.sort();
|
|
131
|
+
|
|
132
|
+
assert_eq!(ryl_list, y_list, "file lists should match");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#[test]
|
|
136
|
+
fn ignore_from_file_can_reinclude_file_from_excluded_directory_matches_yamllint() {
|
|
137
|
+
ensure_yamllint_installed();
|
|
138
|
+
|
|
139
|
+
let td = tempdir().unwrap();
|
|
140
|
+
let root = td.path();
|
|
141
|
+
fs::write(
|
|
142
|
+
root.join(".yamllint"),
|
|
143
|
+
"ignore-from-file: patterns.ignore\nrules: {}\n",
|
|
144
|
+
)
|
|
145
|
+
.unwrap();
|
|
146
|
+
fs::write(root.join("patterns.ignore"), "build/\n!build/keep.yaml\n").unwrap();
|
|
147
|
+
fs::create_dir_all(root.join("build")).unwrap();
|
|
148
|
+
fs::write(root.join("build/keep.yaml"), "ok: 1\n").unwrap();
|
|
149
|
+
fs::write(root.join("build/drop.yaml"), "ok: 1\n").unwrap();
|
|
150
|
+
fs::write(root.join("top.yaml"), "ok: 1\n").unwrap();
|
|
151
|
+
|
|
152
|
+
let ryl = env!("CARGO_BIN_EXE_ryl");
|
|
153
|
+
let (_code, ryl_out, ryl_err) = run(Command::new(ryl)
|
|
154
|
+
.current_dir(root)
|
|
155
|
+
.arg("--list-files")
|
|
156
|
+
.arg("."));
|
|
157
|
+
assert!(ryl_err.is_empty(), "unexpected stderr from ryl: {ryl_err}");
|
|
158
|
+
let mut ryl_list: Vec<_> = ryl_out.lines().map(|s| s.to_string()).collect();
|
|
159
|
+
ryl_list.sort();
|
|
160
|
+
|
|
161
|
+
let (_yc, y_out, y_err) = run(Command::new("yamllint")
|
|
162
|
+
.current_dir(root)
|
|
163
|
+
.arg("--list-files")
|
|
164
|
+
.arg("."));
|
|
165
|
+
assert!(y_err.is_empty(), "unexpected stderr from yamllint: {y_err}");
|
|
166
|
+
let mut y_list: Vec<_> = y_out.lines().map(|s| s.to_string()).collect();
|
|
167
|
+
y_list.sort();
|
|
168
|
+
|
|
169
|
+
assert_eq!(ryl_list, y_list, "file lists should match");
|
|
170
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
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 document_end_rule_matches_yamllint() {
|
|
15
|
+
ensure_yamllint_installed();
|
|
16
|
+
|
|
17
|
+
let dir = tempdir().unwrap();
|
|
18
|
+
|
|
19
|
+
let missing = dir.path().join("missing.yaml");
|
|
20
|
+
fs::write(&missing, "---\nfoo: bar\n").unwrap();
|
|
21
|
+
|
|
22
|
+
let explicit = dir.path().join("explicit.yaml");
|
|
23
|
+
fs::write(&explicit, "---\nfoo: bar\n...\n").unwrap();
|
|
24
|
+
|
|
25
|
+
let explicit_with_comment = dir.path().join("explicit_with_comment.yaml");
|
|
26
|
+
fs::write(&explicit_with_comment, "---\nfoo: bar\n... # done\n").unwrap();
|
|
27
|
+
|
|
28
|
+
let require_cfg = dir.path().join("require.yml");
|
|
29
|
+
fs::write(
|
|
30
|
+
&require_cfg,
|
|
31
|
+
"rules:\n document-end:\n level: error\n present: true\n",
|
|
32
|
+
)
|
|
33
|
+
.unwrap();
|
|
34
|
+
|
|
35
|
+
let forbid_cfg = dir.path().join("forbid.yml");
|
|
36
|
+
fs::write(
|
|
37
|
+
&forbid_cfg,
|
|
38
|
+
"rules:\n document-end:\n level: error\n present: false\n",
|
|
39
|
+
)
|
|
40
|
+
.unwrap();
|
|
41
|
+
|
|
42
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
43
|
+
|
|
44
|
+
for scenario in SCENARIOS {
|
|
45
|
+
let mut ryl_require = build_ryl_command(exe, scenario.ryl_format);
|
|
46
|
+
ryl_require.arg("-c").arg(&require_cfg).arg(&missing);
|
|
47
|
+
let (ryl_req_code, ryl_req_msg) = capture_with_env(ryl_require, scenario.envs);
|
|
48
|
+
|
|
49
|
+
let mut yam_require = build_yamllint_command(scenario.yam_format);
|
|
50
|
+
yam_require.arg("-c").arg(&require_cfg).arg(&missing);
|
|
51
|
+
let (yam_req_code, yam_req_msg) = capture_with_env(yam_require, scenario.envs);
|
|
52
|
+
|
|
53
|
+
assert_eq!(ryl_req_code, 1, "ryl require exit ({})", scenario.label);
|
|
54
|
+
assert_eq!(
|
|
55
|
+
yam_req_code, 1,
|
|
56
|
+
"yamllint require exit ({})",
|
|
57
|
+
scenario.label
|
|
58
|
+
);
|
|
59
|
+
assert_eq!(
|
|
60
|
+
ryl_req_msg, yam_req_msg,
|
|
61
|
+
"missing marker diagnostics mismatch ({})",
|
|
62
|
+
scenario.label
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
let mut ryl_require_ok = build_ryl_command(exe, scenario.ryl_format);
|
|
66
|
+
ryl_require_ok.arg("-c").arg(&require_cfg).arg(&explicit);
|
|
67
|
+
let (ryl_req_ok_code, ryl_req_ok_msg) =
|
|
68
|
+
capture_with_env(ryl_require_ok, scenario.envs);
|
|
69
|
+
|
|
70
|
+
let mut yam_require_ok = build_yamllint_command(scenario.yam_format);
|
|
71
|
+
yam_require_ok.arg("-c").arg(&require_cfg).arg(&explicit);
|
|
72
|
+
let (yam_req_ok_code, yam_req_ok_msg) =
|
|
73
|
+
capture_with_env(yam_require_ok, scenario.envs);
|
|
74
|
+
|
|
75
|
+
assert_eq!(
|
|
76
|
+
ryl_req_ok_code, 0,
|
|
77
|
+
"ryl require pass exit ({})",
|
|
78
|
+
scenario.label
|
|
79
|
+
);
|
|
80
|
+
assert_eq!(
|
|
81
|
+
yam_req_ok_code, 0,
|
|
82
|
+
"yamllint require pass exit ({})",
|
|
83
|
+
scenario.label
|
|
84
|
+
);
|
|
85
|
+
assert_eq!(
|
|
86
|
+
ryl_req_ok_msg, yam_req_ok_msg,
|
|
87
|
+
"require pass diagnostics mismatch ({})",
|
|
88
|
+
scenario.label
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
let mut ryl_require_comment = build_ryl_command(exe, scenario.ryl_format);
|
|
92
|
+
ryl_require_comment
|
|
93
|
+
.arg("-c")
|
|
94
|
+
.arg(&require_cfg)
|
|
95
|
+
.arg(&explicit_with_comment);
|
|
96
|
+
let (ryl_req_comment_code, ryl_req_comment_msg) =
|
|
97
|
+
capture_with_env(ryl_require_comment, scenario.envs);
|
|
98
|
+
|
|
99
|
+
let mut yam_require_comment = build_yamllint_command(scenario.yam_format);
|
|
100
|
+
yam_require_comment
|
|
101
|
+
.arg("-c")
|
|
102
|
+
.arg(&require_cfg)
|
|
103
|
+
.arg(&explicit_with_comment);
|
|
104
|
+
let (yam_req_comment_code, yam_req_comment_msg) =
|
|
105
|
+
capture_with_env(yam_require_comment, scenario.envs);
|
|
106
|
+
|
|
107
|
+
assert_eq!(
|
|
108
|
+
ryl_req_comment_code, 0,
|
|
109
|
+
"ryl require pass (with comment) exit ({})",
|
|
110
|
+
scenario.label
|
|
111
|
+
);
|
|
112
|
+
assert_eq!(
|
|
113
|
+
yam_req_comment_code, 0,
|
|
114
|
+
"yamllint require pass (with comment) exit ({})",
|
|
115
|
+
scenario.label
|
|
116
|
+
);
|
|
117
|
+
assert_eq!(
|
|
118
|
+
ryl_req_comment_msg, yam_req_comment_msg,
|
|
119
|
+
"require comment diagnostics mismatch ({})",
|
|
120
|
+
scenario.label
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
let mut ryl_forbid = build_ryl_command(exe, scenario.ryl_format);
|
|
124
|
+
ryl_forbid.arg("-c").arg(&forbid_cfg).arg(&explicit);
|
|
125
|
+
let (ryl_forbid_code, ryl_forbid_msg) =
|
|
126
|
+
capture_with_env(ryl_forbid, scenario.envs);
|
|
127
|
+
|
|
128
|
+
let mut yam_forbid = build_yamllint_command(scenario.yam_format);
|
|
129
|
+
yam_forbid.arg("-c").arg(&forbid_cfg).arg(&explicit);
|
|
130
|
+
let (yam_forbid_code, yam_forbid_msg) =
|
|
131
|
+
capture_with_env(yam_forbid, scenario.envs);
|
|
132
|
+
|
|
133
|
+
assert_eq!(ryl_forbid_code, 1, "ryl forbid exit ({})", scenario.label);
|
|
134
|
+
assert_eq!(
|
|
135
|
+
yam_forbid_code, 1,
|
|
136
|
+
"yamllint forbid exit ({})",
|
|
137
|
+
scenario.label
|
|
138
|
+
);
|
|
139
|
+
assert_eq!(
|
|
140
|
+
ryl_forbid_msg, yam_forbid_msg,
|
|
141
|
+
"forbid diagnostics mismatch ({})",
|
|
142
|
+
scenario.label
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
let mut ryl_forbid_comment = build_ryl_command(exe, scenario.ryl_format);
|
|
146
|
+
ryl_forbid_comment
|
|
147
|
+
.arg("-c")
|
|
148
|
+
.arg(&forbid_cfg)
|
|
149
|
+
.arg(&explicit_with_comment);
|
|
150
|
+
let (ryl_forbid_comment_code, ryl_forbid_comment_msg) =
|
|
151
|
+
capture_with_env(ryl_forbid_comment, scenario.envs);
|
|
152
|
+
|
|
153
|
+
let mut yam_forbid_comment = build_yamllint_command(scenario.yam_format);
|
|
154
|
+
yam_forbid_comment
|
|
155
|
+
.arg("-c")
|
|
156
|
+
.arg(&forbid_cfg)
|
|
157
|
+
.arg(&explicit_with_comment);
|
|
158
|
+
let (yam_forbid_comment_code, yam_forbid_comment_msg) =
|
|
159
|
+
capture_with_env(yam_forbid_comment, scenario.envs);
|
|
160
|
+
|
|
161
|
+
assert_eq!(
|
|
162
|
+
ryl_forbid_comment_code, 1,
|
|
163
|
+
"ryl forbid comment exit ({})",
|
|
164
|
+
scenario.label
|
|
165
|
+
);
|
|
166
|
+
assert_eq!(
|
|
167
|
+
yam_forbid_comment_code, 1,
|
|
168
|
+
"yamllint forbid comment exit ({})",
|
|
169
|
+
scenario.label
|
|
170
|
+
);
|
|
171
|
+
assert_eq!(
|
|
172
|
+
ryl_forbid_comment_msg, yam_forbid_comment_msg,
|
|
173
|
+
"forbid comment diagnostics mismatch ({})",
|
|
174
|
+
scenario.label
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
let mut ryl_forbid_ok = build_ryl_command(exe, scenario.ryl_format);
|
|
178
|
+
ryl_forbid_ok.arg("-c").arg(&forbid_cfg).arg(&missing);
|
|
179
|
+
let (ryl_forbid_ok_code, ryl_forbid_ok_msg) =
|
|
180
|
+
capture_with_env(ryl_forbid_ok, scenario.envs);
|
|
181
|
+
|
|
182
|
+
let mut yam_forbid_ok = build_yamllint_command(scenario.yam_format);
|
|
183
|
+
yam_forbid_ok.arg("-c").arg(&forbid_cfg).arg(&missing);
|
|
184
|
+
let (yam_forbid_ok_code, yam_forbid_ok_msg) =
|
|
185
|
+
capture_with_env(yam_forbid_ok, scenario.envs);
|
|
186
|
+
|
|
187
|
+
assert_eq!(
|
|
188
|
+
ryl_forbid_ok_code, 0,
|
|
189
|
+
"ryl forbid pass exit ({})",
|
|
190
|
+
scenario.label
|
|
191
|
+
);
|
|
192
|
+
assert_eq!(
|
|
193
|
+
yam_forbid_ok_code, 0,
|
|
194
|
+
"yamllint forbid pass exit ({})",
|
|
195
|
+
scenario.label
|
|
196
|
+
);
|
|
197
|
+
assert_eq!(
|
|
198
|
+
ryl_forbid_ok_msg, yam_forbid_ok_msg,
|
|
199
|
+
"forbid pass diagnostics mismatch ({})",
|
|
200
|
+
scenario.label
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
#[test]
|
|
206
|
+
fn document_end_handles_unicode_scalars() {
|
|
207
|
+
ensure_yamllint_installed();
|
|
208
|
+
|
|
209
|
+
let dir = tempdir().unwrap();
|
|
210
|
+
|
|
211
|
+
let cfg_path = dir.path().join("config.yaml");
|
|
212
|
+
fs::write(
|
|
213
|
+
&cfg_path,
|
|
214
|
+
"rules:\n document-start: disable\n document-end:\n level: error\n present: false\n",
|
|
215
|
+
)
|
|
216
|
+
.unwrap();
|
|
217
|
+
|
|
218
|
+
let yaml_path = dir.path().join("unicode.yaml");
|
|
219
|
+
fs::write(
|
|
220
|
+
&yaml_path,
|
|
221
|
+
"set_room_temperature:\n fields:\n comfort_temp:\n selector:\n number:\n min: 0\n max: 100\n unit_of_measurement: \"°\"\n",
|
|
222
|
+
)
|
|
223
|
+
.unwrap();
|
|
224
|
+
|
|
225
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
226
|
+
|
|
227
|
+
for scenario in SCENARIOS {
|
|
228
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
229
|
+
ryl_cmd.arg("-c").arg(&cfg_path).arg(&yaml_path);
|
|
230
|
+
let (ryl_code, ryl_output) = capture_with_env(ryl_cmd, scenario.envs);
|
|
231
|
+
|
|
232
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
233
|
+
yam_cmd.arg("-c").arg(&cfg_path).arg(&yaml_path);
|
|
234
|
+
let (yam_code, yam_output) = capture_with_env(yam_cmd, scenario.envs);
|
|
235
|
+
|
|
236
|
+
assert_eq!(ryl_code, yam_code, "exit mismatch ({})", scenario.label);
|
|
237
|
+
assert_eq!(
|
|
238
|
+
ryl_output, yam_output,
|
|
239
|
+
"diagnostics mismatch ({})",
|
|
240
|
+
scenario.label
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|