@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,139 +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 key_duplicates_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let default_cfg = dir.path().join("key-duplicates-default.yml");
20
- fs::write(
21
- &default_cfg,
22
- "rules:\n document-start: disable\n key-duplicates: enable\n",
23
- )
24
- .unwrap();
25
-
26
- let forbid_cfg = dir.path().join("key-duplicates-forbid.yml");
27
- fs::write(
28
- &forbid_cfg,
29
- "rules:\n document-start: disable\n key-duplicates:\n forbid-duplicated-merge-keys: true\n",
30
- )
31
- .unwrap();
32
-
33
- let dup_bad = dir.path().join("dup-bad.yaml");
34
- fs::write(&dup_bad, "foo: 1\nbar: 2\nfoo: 3\n").unwrap();
35
-
36
- let dup_ok = dir.path().join("dup-ok.yaml");
37
- fs::write(&dup_ok, "foo: 1\nbar: 2\n").unwrap();
38
-
39
- let merge_dup = dir.path().join("merge-dup.yaml");
40
- fs::write(
41
- &merge_dup,
42
- "anchor: &a\n value: 1\nmerged:\n <<: *a\n <<: *a\n",
43
- )
44
- .unwrap();
45
-
46
- let exe = env!("CARGO_BIN_EXE_ryl");
47
-
48
- for scenario in SCENARIOS {
49
- let mut ryl_bad = build_ryl_command(exe, scenario.ryl_format);
50
- ryl_bad.arg("-c").arg(&default_cfg).arg(&dup_bad);
51
- let (ryl_bad_code, ryl_bad_msg) = capture_with_env(ryl_bad, scenario.envs);
52
-
53
- let mut yam_bad = build_yamllint_command(scenario.yam_format);
54
- yam_bad.arg("-c").arg(&default_cfg).arg(&dup_bad);
55
- let (yam_bad_code, yam_bad_msg) = capture_with_env(yam_bad, scenario.envs);
56
-
57
- assert_eq!(ryl_bad_code, 1, "ryl dup exit ({})", scenario.label);
58
- assert_eq!(yam_bad_code, 1, "yamllint dup exit ({})", scenario.label);
59
- assert_eq!(
60
- ryl_bad_msg, yam_bad_msg,
61
- "duplicate diagnostics mismatch ({})",
62
- scenario.label
63
- );
64
-
65
- let mut ryl_ok = build_ryl_command(exe, scenario.ryl_format);
66
- ryl_ok.arg("-c").arg(&default_cfg).arg(&dup_ok);
67
- let (ryl_ok_code, ryl_ok_msg) = capture_with_env(ryl_ok, scenario.envs);
68
-
69
- let mut yam_ok = build_yamllint_command(scenario.yam_format);
70
- yam_ok.arg("-c").arg(&default_cfg).arg(&dup_ok);
71
- let (yam_ok_code, yam_ok_msg) = capture_with_env(yam_ok, scenario.envs);
72
-
73
- assert_eq!(ryl_ok_code, 0, "ryl ok exit ({})", scenario.label);
74
- assert_eq!(yam_ok_code, 0, "yamllint ok exit ({})", scenario.label);
75
- assert_eq!(
76
- ryl_ok_msg, yam_ok_msg,
77
- "ok diagnostics mismatch ({})",
78
- scenario.label
79
- );
80
-
81
- let mut ryl_merge_default = build_ryl_command(exe, scenario.ryl_format);
82
- ryl_merge_default
83
- .arg("-c")
84
- .arg(&default_cfg)
85
- .arg(&merge_dup);
86
- let (ryl_merge_def_code, ryl_merge_def_msg) =
87
- capture_with_env(ryl_merge_default, scenario.envs);
88
-
89
- let mut yam_merge_default = build_yamllint_command(scenario.yam_format);
90
- yam_merge_default
91
- .arg("-c")
92
- .arg(&default_cfg)
93
- .arg(&merge_dup);
94
- let (yam_merge_def_code, yam_merge_def_msg) =
95
- capture_with_env(yam_merge_default, scenario.envs);
96
-
97
- assert_eq!(
98
- ryl_merge_def_code, 0,
99
- "ryl merge default exit ({})",
100
- scenario.label
101
- );
102
- assert_eq!(
103
- yam_merge_def_code, 0,
104
- "yamllint merge default exit ({})",
105
- scenario.label
106
- );
107
- assert_eq!(
108
- ryl_merge_def_msg, yam_merge_def_msg,
109
- "merge default diagnostics mismatch ({})",
110
- scenario.label
111
- );
112
-
113
- let mut ryl_merge_forbid = build_ryl_command(exe, scenario.ryl_format);
114
- ryl_merge_forbid.arg("-c").arg(&forbid_cfg).arg(&merge_dup);
115
- let (ryl_merge_forbid_code, ryl_merge_forbid_msg) =
116
- capture_with_env(ryl_merge_forbid, scenario.envs);
117
-
118
- let mut yam_merge_forbid = build_yamllint_command(scenario.yam_format);
119
- yam_merge_forbid.arg("-c").arg(&forbid_cfg).arg(&merge_dup);
120
- let (yam_merge_forbid_code, yam_merge_forbid_msg) =
121
- capture_with_env(yam_merge_forbid, scenario.envs);
122
-
123
- assert_eq!(
124
- ryl_merge_forbid_code, 1,
125
- "ryl merge forbid exit ({})",
126
- scenario.label
127
- );
128
- assert_eq!(
129
- yam_merge_forbid_code, 1,
130
- "yamllint merge forbid exit ({})",
131
- scenario.label
132
- );
133
- assert_eq!(
134
- ryl_merge_forbid_msg, yam_merge_forbid_msg,
135
- "merge forbid diagnostics mismatch ({})",
136
- scenario.label
137
- );
138
- }
139
- }
@@ -1,170 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- #[path = "common/compat.rs"]
7
- mod compat;
8
-
9
- use compat::{
10
- SCENARIOS, STANDARD_ENV, build_ryl_command, build_yamllint_command,
11
- capture_with_env, ensure_yamllint_installed,
12
- };
13
-
14
- #[test]
15
- fn key_ordering_matches_yamllint() {
16
- ensure_yamllint_installed();
17
-
18
- let dir = tempdir().unwrap();
19
-
20
- let default_cfg = dir.path().join("key-ordering-default.yml");
21
- fs::write(
22
- &default_cfg,
23
- "rules:\n document-start: disable\n key-ordering: enable\n",
24
- )
25
- .unwrap();
26
-
27
- let ignored_cfg = dir.path().join("key-ordering-ignored.yml");
28
- fs::write(
29
- &ignored_cfg,
30
- "rules:\n document-start: disable\n key-ordering:\n ignored-keys: [\"n(a|o)me\", \"^b\"]\n",
31
- )
32
- .unwrap();
33
-
34
- let locale_cfg = dir.path().join("key-ordering-locale.yml");
35
- fs::write(
36
- &locale_cfg,
37
- "locale: en_US.UTF-8\nrules:\n document-start: disable\n key-ordering: enable\n",
38
- )
39
- .unwrap();
40
-
41
- let bad_block = dir.path().join("bad-block.yaml");
42
- fs::write(
43
- &bad_block,
44
- "block mapping:\n second: value\n first: value\n",
45
- )
46
- .unwrap();
47
-
48
- let good_block = dir.path().join("good-block.yaml");
49
- fs::write(
50
- &good_block,
51
- "block mapping:\n first: value\n second: value\n third: v\n",
52
- )
53
- .unwrap();
54
-
55
- let ignored_file = dir.path().join("ignored.yaml");
56
- fs::write(
57
- &ignored_file,
58
- "a:\nb:\nc:\nname: ignored\nfirst-name: ignored\nnome: ignored\ngnomes: ignored\nd:\ne:\nboat: ignored\n.boat: ERROR\ncall: ERROR\nf:\ng:\n",
59
- )
60
- .unwrap();
61
-
62
- let locale_file = dir.path().join("locale.yaml");
63
- fs::write(
64
- &locale_file,
65
- "- t-shirt: 1\n T-shirt: 2\n t-shirts: 3\n T-shirts: 4\n- hair: true\n haïr: true\n hais: true\n haïssable: true\n",
66
- )
67
- .unwrap();
68
-
69
- // Probe locale availability before running the full matrix. Skip locale comparison when
70
- // yamllint cannot set the configured locale.
71
- let mut locale_probe = Command::new("yamllint");
72
- locale_probe.arg("-c").arg(&locale_cfg).arg(&locale_file);
73
- let (probe_code, probe_output) = capture_with_env(locale_probe, STANDARD_ENV);
74
- let skip_locale = if probe_code != 0
75
- && (probe_output.contains("unsupported locale")
76
- || probe_output.contains("unknown locale"))
77
- {
78
- eprintln!("skipping locale comparison: {probe_output}");
79
- true
80
- } else {
81
- false
82
- };
83
-
84
- let exe = env!("CARGO_BIN_EXE_ryl");
85
-
86
- for scenario in SCENARIOS {
87
- // default configuration, expect violations on bad block
88
- let mut ryl_bad = build_ryl_command(exe, scenario.ryl_format);
89
- ryl_bad.arg("-c").arg(&default_cfg).arg(&bad_block);
90
- let (ryl_bad_code, ryl_bad_msg) = capture_with_env(ryl_bad, scenario.envs);
91
-
92
- let mut yam_bad = build_yamllint_command(scenario.yam_format);
93
- yam_bad.arg("-c").arg(&default_cfg).arg(&bad_block);
94
- let (yam_bad_code, yam_bad_msg) = capture_with_env(yam_bad, scenario.envs);
95
-
96
- assert_eq!(ryl_bad_code, 1, "ryl bad exit ({})", scenario.label);
97
- assert_eq!(yam_bad_code, 1, "yamllint bad exit ({})", scenario.label);
98
- assert_eq!(
99
- ryl_bad_msg, yam_bad_msg,
100
- "bad block diagnostics mismatch ({})",
101
- scenario.label
102
- );
103
-
104
- // good block should be clean
105
- let mut ryl_good = build_ryl_command(exe, scenario.ryl_format);
106
- ryl_good.arg("-c").arg(&default_cfg).arg(&good_block);
107
- let (ryl_good_code, ryl_good_msg) = capture_with_env(ryl_good, scenario.envs);
108
-
109
- let mut yam_good = build_yamllint_command(scenario.yam_format);
110
- yam_good.arg("-c").arg(&default_cfg).arg(&good_block);
111
- let (yam_good_code, yam_good_msg) = capture_with_env(yam_good, scenario.envs);
112
-
113
- assert_eq!(ryl_good_code, 0, "ryl good exit ({})", scenario.label);
114
- assert_eq!(yam_good_code, 0, "yamllint good exit ({})", scenario.label);
115
- assert_eq!(
116
- ryl_good_msg, yam_good_msg,
117
- "good block diagnostics mismatch ({})",
118
- scenario.label
119
- );
120
-
121
- // ignored-keys configuration should allow ignored patterns and flag others equally
122
- let mut ryl_ignored = build_ryl_command(exe, scenario.ryl_format);
123
- ryl_ignored.arg("-c").arg(&ignored_cfg).arg(&ignored_file);
124
- let (ryl_ignored_code, ryl_ignored_msg) =
125
- capture_with_env(ryl_ignored, scenario.envs);
126
-
127
- let mut yam_ignored = build_yamllint_command(scenario.yam_format);
128
- yam_ignored.arg("-c").arg(&ignored_cfg).arg(&ignored_file);
129
- let (yam_ignored_code, yam_ignored_msg) =
130
- capture_with_env(yam_ignored, scenario.envs);
131
-
132
- assert_eq!(ryl_ignored_code, 1, "ryl ignored exit ({})", scenario.label);
133
- assert_eq!(
134
- yam_ignored_code, 1,
135
- "yamllint ignored exit ({})",
136
- scenario.label
137
- );
138
- assert_eq!(
139
- ryl_ignored_msg, yam_ignored_msg,
140
- "ignored diagnostics mismatch ({})",
141
- scenario.label
142
- );
143
-
144
- if skip_locale {
145
- continue;
146
- }
147
-
148
- let mut ryl_locale = build_ryl_command(exe, scenario.ryl_format);
149
- ryl_locale.arg("-c").arg(&locale_cfg).arg(&locale_file);
150
- let (ryl_locale_code, ryl_locale_msg) =
151
- capture_with_env(ryl_locale, scenario.envs);
152
-
153
- let mut yam_locale = build_yamllint_command(scenario.yam_format);
154
- yam_locale.arg("-c").arg(&locale_cfg).arg(&locale_file);
155
- let (yam_locale_code, yam_locale_msg) =
156
- capture_with_env(yam_locale, scenario.envs);
157
-
158
- assert_eq!(ryl_locale_code, 0, "ryl locale exit ({})", scenario.label);
159
- assert_eq!(
160
- yam_locale_code, 0,
161
- "yamllint locale exit ({})",
162
- scenario.label
163
- );
164
- assert_eq!(
165
- ryl_locale_msg, yam_locale_msg,
166
- "locale diagnostics mismatch ({})",
167
- scenario.label
168
- );
169
- }
170
- }
@@ -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 line_length_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let default_cfg = dir.path().join("line-default.yml");
20
- fs::write(
21
- &default_cfg,
22
- "rules:\n document-start: disable\n empty-lines: disable\n new-line-at-end-of-file: disable\n line-length:\n max: 80\n",
23
- )
24
- .unwrap();
25
-
26
- let warning_cfg = dir.path().join("line-warning.yml");
27
- fs::write(
28
- &warning_cfg,
29
- "rules:\n document-start: disable\n empty-lines: disable\n new-line-at-end-of-file: disable\n line-length:\n max: 80\n level: warning\n",
30
- )
31
- .unwrap();
32
-
33
- let strict_cfg = dir.path().join("line-strict.yml");
34
- fs::write(
35
- &strict_cfg,
36
- "rules:\n document-start: disable\n line-length:\n max: 20\n allow-non-breakable-words: false\n",
37
- )
38
- .unwrap();
39
-
40
- let inline_cfg = dir.path().join("line-inline.yml");
41
- fs::write(
42
- &inline_cfg,
43
- "rules:\n document-start: disable\n line-length:\n max: 20\n allow-non-breakable-inline-mappings: true\n",
44
- )
45
- .unwrap();
46
-
47
- let bad_file = dir.path().join("bad.yaml");
48
- fs::write(
49
- &bad_file,
50
- "key: this line is definitely longer than eighty characters so yamllint and ryl should both flag it\n",
51
- )
52
- .unwrap();
53
-
54
- let long_word_file = dir.path().join("long_word.yaml");
55
- fs::write(&long_word_file, format!("{}\n", "A".repeat(50))).unwrap();
56
-
57
- let inline_ok_file = dir.path().join("inline_ok.yaml");
58
- fs::write(
59
- &inline_ok_file,
60
- "url: http://example.com/very/very/very/very/very/very/long/path\n",
61
- )
62
- .unwrap();
63
-
64
- let inline_bad_file = dir.path().join("inline_bad.yaml");
65
- fs::write(
66
- &inline_bad_file,
67
- "url: http://example.com/short + extra words to trigger the rule\n",
68
- )
69
- .unwrap();
70
-
71
- let exe = env!("CARGO_BIN_EXE_ryl");
72
-
73
- for scenario in SCENARIOS {
74
- // default configuration should produce an error for spaced text
75
- let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
76
- ryl_default.arg("-c").arg(&default_cfg).arg(&bad_file);
77
- let (ryl_code, ryl_output) = capture_with_env(ryl_default, scenario.envs);
78
-
79
- let mut yam_default = build_yamllint_command(scenario.yam_format);
80
- yam_default.arg("-c").arg(&default_cfg).arg(&bad_file);
81
- let (yam_code, yam_output) = capture_with_env(yam_default, scenario.envs);
82
-
83
- assert_eq!(ryl_code, 1, "ryl default exit ({})", scenario.label);
84
- assert_eq!(yam_code, 1, "yamllint default exit ({})", scenario.label);
85
- assert_eq!(
86
- ryl_output, yam_output,
87
- "default diagnostics mismatch ({})",
88
- scenario.label
89
- );
90
-
91
- // warning configuration should keep diagnostics but exit 0
92
- let mut ryl_warning = build_ryl_command(exe, scenario.ryl_format);
93
- ryl_warning.arg("-c").arg(&warning_cfg).arg(&bad_file);
94
- let (ryl_warn_code, ryl_warn_output) =
95
- capture_with_env(ryl_warning, scenario.envs);
96
-
97
- let mut yam_warning = build_yamllint_command(scenario.yam_format);
98
- yam_warning.arg("-c").arg(&warning_cfg).arg(&bad_file);
99
- let (yam_warn_code, yam_warn_output) =
100
- capture_with_env(yam_warning, scenario.envs);
101
-
102
- assert_eq!(ryl_warn_code, 0, "ryl warning exit ({})", scenario.label);
103
- assert_eq!(
104
- yam_warn_code, 0,
105
- "yamllint warning exit ({})",
106
- scenario.label
107
- );
108
- assert_eq!(
109
- ryl_warn_output, yam_warn_output,
110
- "warning diagnostics mismatch ({})",
111
- scenario.label
112
- );
113
-
114
- // strict configuration should flag long non-breakable words
115
- let mut ryl_strict = build_ryl_command(exe, scenario.ryl_format);
116
- ryl_strict.arg("-c").arg(&strict_cfg).arg(&long_word_file);
117
- let (ryl_strict_code, ryl_strict_output) =
118
- capture_with_env(ryl_strict, scenario.envs);
119
-
120
- let mut yam_strict = build_yamllint_command(scenario.yam_format);
121
- yam_strict.arg("-c").arg(&strict_cfg).arg(&long_word_file);
122
- let (yam_strict_code, yam_strict_output) =
123
- capture_with_env(yam_strict, scenario.envs);
124
-
125
- assert_eq!(ryl_strict_code, 1, "ryl strict exit ({})", scenario.label);
126
- assert_eq!(
127
- yam_strict_code, 1,
128
- "yamllint strict exit ({})",
129
- scenario.label
130
- );
131
- assert_eq!(
132
- ryl_strict_output, yam_strict_output,
133
- "strict diagnostics mismatch ({})",
134
- scenario.label
135
- );
136
-
137
- // inline mapping allowance should let long URLs through
138
- let mut ryl_inline_ok = build_ryl_command(exe, scenario.ryl_format);
139
- ryl_inline_ok
140
- .arg("-c")
141
- .arg(&inline_cfg)
142
- .arg(&inline_ok_file);
143
- let (ryl_inline_code, ryl_inline_output) =
144
- capture_with_env(ryl_inline_ok, scenario.envs);
145
-
146
- let mut yam_inline_ok = build_yamllint_command(scenario.yam_format);
147
- yam_inline_ok
148
- .arg("-c")
149
- .arg(&inline_cfg)
150
- .arg(&inline_ok_file);
151
- let (yam_inline_code, yam_inline_output) =
152
- capture_with_env(yam_inline_ok, scenario.envs);
153
-
154
- assert_eq!(
155
- ryl_inline_code, 0,
156
- "ryl inline-ok exit ({})",
157
- scenario.label
158
- );
159
- assert_eq!(
160
- yam_inline_code, 0,
161
- "yamllint inline-ok exit ({})",
162
- scenario.label
163
- );
164
- assert_eq!(
165
- ryl_inline_output, yam_inline_output,
166
- "inline ok diagnostics mismatch ({})",
167
- scenario.label
168
- );
169
-
170
- // inline mapping option should still flag when spaces remain
171
- let mut ryl_inline_bad = build_ryl_command(exe, scenario.ryl_format);
172
- ryl_inline_bad
173
- .arg("-c")
174
- .arg(&inline_cfg)
175
- .arg(&inline_bad_file);
176
- let (ryl_inline_bad_code, ryl_inline_bad_output) =
177
- capture_with_env(ryl_inline_bad, scenario.envs);
178
-
179
- let mut yam_inline_bad = build_yamllint_command(scenario.yam_format);
180
- yam_inline_bad
181
- .arg("-c")
182
- .arg(&inline_cfg)
183
- .arg(&inline_bad_file);
184
- let (yam_inline_bad_code, yam_inline_bad_output) =
185
- capture_with_env(yam_inline_bad, scenario.envs);
186
-
187
- assert_eq!(
188
- ryl_inline_bad_code, 1,
189
- "ryl inline-bad exit ({})",
190
- scenario.label
191
- );
192
- assert_eq!(
193
- yam_inline_bad_code, 1,
194
- "yamllint inline-bad exit ({})",
195
- scenario.label
196
- );
197
- assert_eq!(
198
- ryl_inline_bad_output, yam_inline_bad_output,
199
- "inline bad diagnostics mismatch ({})",
200
- scenario.label
201
- );
202
- }
203
- }
204
-
205
- #[test]
206
- fn line_length_disable_enable_comments_match_yamllint() {
207
- ensure_yamllint_installed();
208
-
209
- let dir = tempdir().unwrap();
210
- let cfg = dir.path().join("line-110.yml");
211
- fs::write(
212
- &cfg,
213
- "extends: default\nrules:\n line-length:\n max: 110\n",
214
- )
215
- .unwrap();
216
-
217
- let input = dir.path().join("line-disable-comments.yaml");
218
- fs::write(
219
- &input,
220
- "# yamllint disable rule:line-length\nmsg: \"This is a very very very very very very very very very very very very very very very long line that should be ignored\"\n# yamllint enable rule:line-length\n",
221
- )
222
- .unwrap();
223
-
224
- let exe = env!("CARGO_BIN_EXE_ryl");
225
-
226
- for scenario in SCENARIOS {
227
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
228
- ryl_cmd.arg("-c").arg(&cfg).arg(&input);
229
- let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
230
-
231
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
232
- yam_cmd.arg("-c").arg(&cfg).arg(&input);
233
- let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
234
-
235
- assert_eq!(
236
- ryl_code, yam_code,
237
- "exit mismatch for line-length disable comments ({})",
238
- scenario.label
239
- );
240
- assert_eq!(
241
- ryl_msg, yam_msg,
242
- "diagnostics mismatch for line-length disable comments ({})",
243
- scenario.label
244
- );
245
- }
246
- }
247
-
248
- #[test]
249
- fn line_length_disable_line_applies_to_one_line_only() {
250
- ensure_yamllint_installed();
251
-
252
- let dir = tempdir().unwrap();
253
- let cfg = dir.path().join("line-40.yml");
254
- fs::write(
255
- &cfg,
256
- "extends: default\nrules:\n line-length:\n max: 40\n",
257
- )
258
- .unwrap();
259
-
260
- let input = dir.path().join("line-disable-line.yaml");
261
- fs::write(
262
- &input,
263
- "---\n# yamllint disable-line rule:line-length\nlong: \"01234567890123456789012345678901234567890123456789\"\nlong2: \"01234567890123456789012345678901234567890123456789\"\n",
264
- )
265
- .unwrap();
266
-
267
- let exe = env!("CARGO_BIN_EXE_ryl");
268
-
269
- for scenario in SCENARIOS {
270
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
271
- ryl_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
272
- let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
273
-
274
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
275
- yam_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
276
- let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
277
-
278
- assert_eq!(
279
- ryl_code, yam_code,
280
- "exit mismatch for line-length disable-line semantics ({})",
281
- scenario.label
282
- );
283
- assert_eq!(
284
- ryl_msg, yam_msg,
285
- "diagnostics mismatch for line-length disable-line semantics ({})",
286
- scenario.label
287
- );
288
- }
289
- }
290
-
291
- #[test]
292
- fn line_length_disable_line_is_consumed_by_next_directive_line() {
293
- ensure_yamllint_installed();
294
-
295
- let dir = tempdir().unwrap();
296
- let cfg = dir.path().join("line-40.yml");
297
- fs::write(
298
- &cfg,
299
- "extends: default\nrules:\n line-length:\n max: 40\n",
300
- )
301
- .unwrap();
302
-
303
- let input = dir.path().join("line-disable-line-directive.yaml");
304
- fs::write(
305
- &input,
306
- "---\n# yamllint disable-line rule:line-length\n# yamllint enable rule:line-length\nlong: \"01234567890123456789012345678901234567890123456789\"\n",
307
- )
308
- .unwrap();
309
-
310
- let exe = env!("CARGO_BIN_EXE_ryl");
311
-
312
- for scenario in SCENARIOS {
313
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
314
- ryl_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
315
- let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
316
-
317
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
318
- yam_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
319
- let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
320
-
321
- assert_eq!(
322
- ryl_code, yam_code,
323
- "exit mismatch for disable-line consumed by directive line ({})",
324
- scenario.label
325
- );
326
- assert_eq!(
327
- ryl_msg, yam_msg,
328
- "diagnostics mismatch for disable-line consumed by directive line ({})",
329
- scenario.label
330
- );
331
- }
332
- }
333
-
334
- #[test]
335
- fn line_length_disable_line_is_consumed_by_blank_line() {
336
- ensure_yamllint_installed();
337
-
338
- let dir = tempdir().unwrap();
339
- let cfg = dir.path().join("line-40.yml");
340
- fs::write(
341
- &cfg,
342
- "extends: default\nrules:\n line-length:\n max: 40\n",
343
- )
344
- .unwrap();
345
-
346
- let input = dir.path().join("line-disable-line-blank.yaml");
347
- fs::write(
348
- &input,
349
- "---\n# yamllint disable-line rule:line-length\n\nlong: \"01234567890123456789012345678901234567890123456789\"\n",
350
- )
351
- .unwrap();
352
-
353
- let exe = env!("CARGO_BIN_EXE_ryl");
354
-
355
- for scenario in SCENARIOS {
356
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
357
- ryl_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
358
- let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
359
-
360
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
361
- yam_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
362
- let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
363
-
364
- assert_eq!(
365
- ryl_code, yam_code,
366
- "exit mismatch for disable-line consumed by blank line ({})",
367
- scenario.label
368
- );
369
- assert_eq!(
370
- ryl_msg, yam_msg,
371
- "diagnostics mismatch for disable-line consumed by blank line ({})",
372
- scenario.label
373
- );
374
- }
375
- }