@owenlamont/ryl 0.4.1 → 0.4.3

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 (217) hide show
  1. package/README.md +13 -0
  2. package/bin/ryl.js +96 -1
  3. package/npm-platforms.json +124 -0
  4. package/package.json +46 -12
  5. package/.github/CODEOWNERS +0 -1
  6. package/.github/dependabot.yml +0 -13
  7. package/.github/workflows/ci.yml +0 -107
  8. package/.github/workflows/release.yml +0 -613
  9. package/.github/workflows/update_dependencies.yml +0 -61
  10. package/.github/workflows/update_linters.yml +0 -56
  11. package/.pre-commit-config.yaml +0 -87
  12. package/.yamllint +0 -4
  13. package/AGENTS.md +0 -200
  14. package/Cargo.lock +0 -908
  15. package/Cargo.toml +0 -32
  16. package/clippy.toml +0 -1
  17. package/docs/config-presets.md +0 -100
  18. package/img/benchmark-5x5-5runs.svg +0 -2176
  19. package/pyproject.toml +0 -42
  20. package/ruff.toml +0 -107
  21. package/rumdl.toml +0 -20
  22. package/rust-toolchain.toml +0 -3
  23. package/rustfmt.toml +0 -3
  24. package/scripts/benchmark_perf_vs_yamllint.py +0 -400
  25. package/scripts/coverage-missing.ps1 +0 -80
  26. package/scripts/coverage-missing.sh +0 -60
  27. package/src/bin/discover_config_bin.rs +0 -24
  28. package/src/cli_support.rs +0 -33
  29. package/src/conf/mod.rs +0 -85
  30. package/src/config.rs +0 -2099
  31. package/src/decoder.rs +0 -326
  32. package/src/discover.rs +0 -31
  33. package/src/lib.rs +0 -19
  34. package/src/lint.rs +0 -558
  35. package/src/main.rs +0 -535
  36. package/src/migrate.rs +0 -233
  37. package/src/rules/anchors.rs +0 -517
  38. package/src/rules/braces.rs +0 -77
  39. package/src/rules/brackets.rs +0 -77
  40. package/src/rules/colons.rs +0 -475
  41. package/src/rules/commas.rs +0 -372
  42. package/src/rules/comments.rs +0 -299
  43. package/src/rules/comments_indentation.rs +0 -243
  44. package/src/rules/document_end.rs +0 -175
  45. package/src/rules/document_start.rs +0 -84
  46. package/src/rules/empty_lines.rs +0 -152
  47. package/src/rules/empty_values.rs +0 -255
  48. package/src/rules/float_values.rs +0 -259
  49. package/src/rules/flow_collection.rs +0 -562
  50. package/src/rules/hyphens.rs +0 -104
  51. package/src/rules/indentation.rs +0 -803
  52. package/src/rules/key_duplicates.rs +0 -218
  53. package/src/rules/key_ordering.rs +0 -303
  54. package/src/rules/line_length.rs +0 -326
  55. package/src/rules/mod.rs +0 -25
  56. package/src/rules/new_line_at_end_of_file.rs +0 -23
  57. package/src/rules/new_lines.rs +0 -95
  58. package/src/rules/octal_values.rs +0 -121
  59. package/src/rules/quoted_strings.rs +0 -577
  60. package/src/rules/span_utils.rs +0 -37
  61. package/src/rules/trailing_spaces.rs +0 -65
  62. package/src/rules/truthy.rs +0 -420
  63. package/tests/brackets_carriage_return.rs +0 -114
  64. package/tests/build_global_cfg_error.rs +0 -23
  65. package/tests/cli_anchors_rule.rs +0 -143
  66. package/tests/cli_braces_rule.rs +0 -104
  67. package/tests/cli_brackets_rule.rs +0 -104
  68. package/tests/cli_colons_rule.rs +0 -65
  69. package/tests/cli_commas_rule.rs +0 -104
  70. package/tests/cli_comments_indentation_rule.rs +0 -61
  71. package/tests/cli_comments_rule.rs +0 -67
  72. package/tests/cli_config_data_error.rs +0 -30
  73. package/tests/cli_config_flags.rs +0 -66
  74. package/tests/cli_config_migrate.rs +0 -229
  75. package/tests/cli_document_end_rule.rs +0 -92
  76. package/tests/cli_document_start_rule.rs +0 -92
  77. package/tests/cli_empty_lines_rule.rs +0 -87
  78. package/tests/cli_empty_values_rule.rs +0 -68
  79. package/tests/cli_env_config.rs +0 -34
  80. package/tests/cli_exit_and_errors.rs +0 -41
  81. package/tests/cli_file_encoding.rs +0 -203
  82. package/tests/cli_float_values_rule.rs +0 -64
  83. package/tests/cli_format_options.rs +0 -316
  84. package/tests/cli_global_cfg_relaxed.rs +0 -20
  85. package/tests/cli_hyphens_rule.rs +0 -104
  86. package/tests/cli_indentation_rule.rs +0 -65
  87. package/tests/cli_invalid_project_config.rs +0 -39
  88. package/tests/cli_key_duplicates_rule.rs +0 -104
  89. package/tests/cli_key_ordering_rule.rs +0 -59
  90. package/tests/cli_line_length_rule.rs +0 -85
  91. package/tests/cli_list_files.rs +0 -29
  92. package/tests/cli_new_line_rule.rs +0 -141
  93. package/tests/cli_new_lines_rule.rs +0 -119
  94. package/tests/cli_octal_values_rule.rs +0 -60
  95. package/tests/cli_quoted_strings_rule.rs +0 -47
  96. package/tests/cli_toml_config.rs +0 -119
  97. package/tests/cli_trailing_spaces_rule.rs +0 -77
  98. package/tests/cli_truthy_rule.rs +0 -83
  99. package/tests/cli_yaml_files_negation.rs +0 -45
  100. package/tests/colons_rule.rs +0 -303
  101. package/tests/common/compat.rs +0 -114
  102. package/tests/common/fake_env.rs +0 -93
  103. package/tests/common/mod.rs +0 -1
  104. package/tests/conf_builtin.rs +0 -9
  105. package/tests/config_anchors.rs +0 -84
  106. package/tests/config_braces.rs +0 -121
  107. package/tests/config_brackets.rs +0 -127
  108. package/tests/config_commas.rs +0 -79
  109. package/tests/config_comments.rs +0 -65
  110. package/tests/config_comments_indentation.rs +0 -20
  111. package/tests/config_deep_merge_nonstring_key.rs +0 -24
  112. package/tests/config_document_end.rs +0 -54
  113. package/tests/config_document_start.rs +0 -55
  114. package/tests/config_empty_lines.rs +0 -48
  115. package/tests/config_empty_values.rs +0 -35
  116. package/tests/config_env_errors.rs +0 -23
  117. package/tests/config_env_invalid_inline.rs +0 -15
  118. package/tests/config_env_missing.rs +0 -63
  119. package/tests/config_env_shim.rs +0 -301
  120. package/tests/config_explicit_file_parse_error.rs +0 -55
  121. package/tests/config_extended_features.rs +0 -225
  122. package/tests/config_extends_inline.rs +0 -185
  123. package/tests/config_extends_sequence.rs +0 -18
  124. package/tests/config_find_project_home_boundary.rs +0 -54
  125. package/tests/config_find_project_two_files_in_cwd.rs +0 -47
  126. package/tests/config_float_values.rs +0 -34
  127. package/tests/config_from_yaml_paths.rs +0 -32
  128. package/tests/config_hyphens.rs +0 -51
  129. package/tests/config_ignore_errors.rs +0 -243
  130. package/tests/config_ignore_overrides.rs +0 -83
  131. package/tests/config_indentation.rs +0 -65
  132. package/tests/config_invalid_globs.rs +0 -16
  133. package/tests/config_invalid_types.rs +0 -19
  134. package/tests/config_key_duplicates.rs +0 -34
  135. package/tests/config_key_ordering.rs +0 -70
  136. package/tests/config_line_length.rs +0 -65
  137. package/tests/config_locale.rs +0 -111
  138. package/tests/config_merge.rs +0 -26
  139. package/tests/config_new_lines.rs +0 -89
  140. package/tests/config_octal_values.rs +0 -33
  141. package/tests/config_quoted_strings.rs +0 -195
  142. package/tests/config_rule_level.rs +0 -147
  143. package/tests/config_rules_non_string_keys.rs +0 -23
  144. package/tests/config_scalar_overrides.rs +0 -27
  145. package/tests/config_to_toml.rs +0 -110
  146. package/tests/config_toml_coverage.rs +0 -80
  147. package/tests/config_toml_discovery.rs +0 -304
  148. package/tests/config_trailing_spaces.rs +0 -152
  149. package/tests/config_truthy.rs +0 -77
  150. package/tests/config_yaml_files.rs +0 -62
  151. package/tests/config_yaml_files_all_non_string.rs +0 -15
  152. package/tests/config_yaml_files_empty.rs +0 -30
  153. package/tests/coverage_commas.rs +0 -46
  154. package/tests/decoder_decode.rs +0 -338
  155. package/tests/discover_config_bin_all.rs +0 -66
  156. package/tests/discover_config_bin_env_invalid_yaml.rs +0 -26
  157. package/tests/discover_config_bin_project_config_parse_error.rs +0 -24
  158. package/tests/discover_config_bin_user_global_error.rs +0 -26
  159. package/tests/discover_module.rs +0 -30
  160. package/tests/discover_per_file_dir.rs +0 -10
  161. package/tests/discover_per_file_project_config_error.rs +0 -21
  162. package/tests/float_values.rs +0 -43
  163. package/tests/lint_multi_errors.rs +0 -32
  164. package/tests/main_yaml_ok_filtering.rs +0 -30
  165. package/tests/migrate_module.rs +0 -259
  166. package/tests/resolve_ctx_empty_parent.rs +0 -16
  167. package/tests/rule_anchors.rs +0 -442
  168. package/tests/rule_braces.rs +0 -258
  169. package/tests/rule_brackets.rs +0 -217
  170. package/tests/rule_commas.rs +0 -205
  171. package/tests/rule_comments.rs +0 -197
  172. package/tests/rule_comments_indentation.rs +0 -127
  173. package/tests/rule_document_end.rs +0 -118
  174. package/tests/rule_document_start.rs +0 -60
  175. package/tests/rule_empty_lines.rs +0 -96
  176. package/tests/rule_empty_values.rs +0 -102
  177. package/tests/rule_float_values.rs +0 -109
  178. package/tests/rule_hyphens.rs +0 -65
  179. package/tests/rule_indentation.rs +0 -455
  180. package/tests/rule_key_duplicates.rs +0 -76
  181. package/tests/rule_key_ordering.rs +0 -207
  182. package/tests/rule_line_length.rs +0 -200
  183. package/tests/rule_new_lines.rs +0 -51
  184. package/tests/rule_octal_values.rs +0 -53
  185. package/tests/rule_quoted_strings.rs +0 -290
  186. package/tests/rule_trailing_spaces.rs +0 -41
  187. package/tests/rule_truthy.rs +0 -236
  188. package/tests/user_global_invalid_yaml.rs +0 -32
  189. package/tests/yamllint_compat_anchors.rs +0 -280
  190. package/tests/yamllint_compat_braces.rs +0 -411
  191. package/tests/yamllint_compat_brackets.rs +0 -364
  192. package/tests/yamllint_compat_colons.rs +0 -298
  193. package/tests/yamllint_compat_colors.rs +0 -80
  194. package/tests/yamllint_compat_commas.rs +0 -375
  195. package/tests/yamllint_compat_comments.rs +0 -167
  196. package/tests/yamllint_compat_comments_indentation.rs +0 -281
  197. package/tests/yamllint_compat_config.rs +0 -170
  198. package/tests/yamllint_compat_document_end.rs +0 -243
  199. package/tests/yamllint_compat_document_start.rs +0 -136
  200. package/tests/yamllint_compat_empty_lines.rs +0 -117
  201. package/tests/yamllint_compat_empty_values.rs +0 -179
  202. package/tests/yamllint_compat_float_values.rs +0 -216
  203. package/tests/yamllint_compat_hyphens.rs +0 -223
  204. package/tests/yamllint_compat_indentation.rs +0 -398
  205. package/tests/yamllint_compat_key_duplicates.rs +0 -139
  206. package/tests/yamllint_compat_key_ordering.rs +0 -170
  207. package/tests/yamllint_compat_line_length.rs +0 -375
  208. package/tests/yamllint_compat_list.rs +0 -127
  209. package/tests/yamllint_compat_new_line.rs +0 -133
  210. package/tests/yamllint_compat_newline_types.rs +0 -185
  211. package/tests/yamllint_compat_octal_values.rs +0 -172
  212. package/tests/yamllint_compat_quoted_strings.rs +0 -154
  213. package/tests/yamllint_compat_syntax.rs +0 -200
  214. package/tests/yamllint_compat_trailing_spaces.rs +0 -162
  215. package/tests/yamllint_compat_truthy.rs +0 -130
  216. package/tests/yamllint_compat_yaml_files.rs +0 -81
  217. package/typos.toml +0 -2
@@ -1,136 +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 document_start_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, "foo: bar\n").unwrap();
21
-
22
- let explicit = dir.path().join("explicit.yaml");
23
- fs::write(&explicit, "---\nfoo: bar\n").unwrap();
24
-
25
- let require_cfg = dir.path().join("require.yml");
26
- fs::write(
27
- &require_cfg,
28
- "rules:\n document-start:\n level: error\n present: true\n",
29
- )
30
- .unwrap();
31
-
32
- let forbid_cfg = dir.path().join("forbid.yml");
33
- fs::write(
34
- &forbid_cfg,
35
- "rules:\n document-start:\n level: error\n present: false\n",
36
- )
37
- .unwrap();
38
-
39
- let exe = env!("CARGO_BIN_EXE_ryl");
40
-
41
- for scenario in SCENARIOS {
42
- let mut ryl_require = build_ryl_command(exe, scenario.ryl_format);
43
- ryl_require.arg("-c").arg(&require_cfg).arg(&missing);
44
- let (ryl_req_code, ryl_req_msg) = capture_with_env(ryl_require, scenario.envs);
45
-
46
- let mut yam_require = build_yamllint_command(scenario.yam_format);
47
- yam_require.arg("-c").arg(&require_cfg).arg(&missing);
48
- let (yam_req_code, yam_req_msg) = capture_with_env(yam_require, scenario.envs);
49
-
50
- assert_eq!(ryl_req_code, 1, "ryl require exit ({})", scenario.label);
51
- assert_eq!(
52
- yam_req_code, 1,
53
- "yamllint require exit ({})",
54
- scenario.label
55
- );
56
- assert_eq!(
57
- ryl_req_msg, yam_req_msg,
58
- "missing marker diagnostics mismatch ({})",
59
- scenario.label
60
- );
61
-
62
- let mut ryl_require_ok = build_ryl_command(exe, scenario.ryl_format);
63
- ryl_require_ok.arg("-c").arg(&require_cfg).arg(&explicit);
64
- let (ryl_req_ok_code, ryl_req_ok_msg) =
65
- capture_with_env(ryl_require_ok, scenario.envs);
66
-
67
- let mut yam_require_ok = build_yamllint_command(scenario.yam_format);
68
- yam_require_ok.arg("-c").arg(&require_cfg).arg(&explicit);
69
- let (yam_req_ok_code, yam_req_ok_msg) =
70
- capture_with_env(yam_require_ok, scenario.envs);
71
-
72
- assert_eq!(
73
- ryl_req_ok_code, 0,
74
- "ryl require pass exit ({})",
75
- scenario.label
76
- );
77
- assert_eq!(
78
- yam_req_ok_code, 0,
79
- "yamllint require pass exit ({})",
80
- scenario.label
81
- );
82
- assert_eq!(
83
- ryl_req_ok_msg, yam_req_ok_msg,
84
- "require pass diagnostics mismatch ({})",
85
- scenario.label
86
- );
87
-
88
- let mut ryl_forbid = build_ryl_command(exe, scenario.ryl_format);
89
- ryl_forbid.arg("-c").arg(&forbid_cfg).arg(&explicit);
90
- let (ryl_forbid_code, ryl_forbid_msg) =
91
- capture_with_env(ryl_forbid, scenario.envs);
92
-
93
- let mut yam_forbid = build_yamllint_command(scenario.yam_format);
94
- yam_forbid.arg("-c").arg(&forbid_cfg).arg(&explicit);
95
- let (yam_forbid_code, yam_forbid_msg) =
96
- capture_with_env(yam_forbid, scenario.envs);
97
-
98
- assert_eq!(ryl_forbid_code, 1, "ryl forbid exit ({})", scenario.label);
99
- assert_eq!(
100
- yam_forbid_code, 1,
101
- "yamllint forbid exit ({})",
102
- scenario.label
103
- );
104
- assert_eq!(
105
- ryl_forbid_msg, yam_forbid_msg,
106
- "forbid diagnostics mismatch ({})",
107
- scenario.label
108
- );
109
-
110
- let mut ryl_forbid_ok = build_ryl_command(exe, scenario.ryl_format);
111
- ryl_forbid_ok.arg("-c").arg(&forbid_cfg).arg(&missing);
112
- let (ryl_forbid_ok_code, ryl_forbid_ok_msg) =
113
- capture_with_env(ryl_forbid_ok, scenario.envs);
114
-
115
- let mut yam_forbid_ok = build_yamllint_command(scenario.yam_format);
116
- yam_forbid_ok.arg("-c").arg(&forbid_cfg).arg(&missing);
117
- let (yam_forbid_ok_code, yam_forbid_ok_msg) =
118
- capture_with_env(yam_forbid_ok, scenario.envs);
119
-
120
- assert_eq!(
121
- ryl_forbid_ok_code, 0,
122
- "ryl forbid pass exit ({})",
123
- scenario.label
124
- );
125
- assert_eq!(
126
- yam_forbid_ok_code, 0,
127
- "yamllint forbid pass exit ({})",
128
- scenario.label
129
- );
130
- assert_eq!(
131
- ryl_forbid_ok_msg, yam_forbid_ok_msg,
132
- "forbid pass diagnostics mismatch ({})",
133
- scenario.label
134
- );
135
- }
136
- }
@@ -1,117 +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: std::path::PathBuf,
16
- target: std::path::PathBuf,
17
- expected_exit: i32,
18
- }
19
-
20
- #[test]
21
- fn empty_lines_rule_matches_yamllint() {
22
- ensure_yamllint_installed();
23
-
24
- let dir = tempdir().unwrap();
25
-
26
- let interior_file = dir.path().join("interior.yaml");
27
- fs::write(&interior_file, "key: 1\n\n\nvalue: 2\n").unwrap();
28
- let start_file = dir.path().join("start.yaml");
29
- fs::write(&start_file, "\n\nkey: 1\n").unwrap();
30
- let end_file = dir.path().join("end.yaml");
31
- fs::write(&end_file, "key: 1\n\n\n").unwrap();
32
-
33
- let interior_cfg = dir.path().join("interior.yml");
34
- fs::write(
35
- &interior_cfg,
36
- "rules:\n document-start: disable\n new-line-at-end-of-file: disable\n empty-lines:\n max: 1\n max-start: 0\n max-end: 0\n",
37
- )
38
- .unwrap();
39
-
40
- let warning_cfg = dir.path().join("warning.yml");
41
- fs::write(
42
- &warning_cfg,
43
- "rules:\n document-start: disable\n new-line-at-end-of-file: disable\n empty-lines:\n level: warning\n max: 1\n max-start: 0\n max-end: 0\n",
44
- )
45
- .unwrap();
46
-
47
- let start_cfg = dir.path().join("start.yml");
48
- fs::write(
49
- &start_cfg,
50
- "rules:\n document-start: disable\n new-line-at-end-of-file: disable\n empty-lines:\n max: 5\n max-start: 1\n max-end: 5\n",
51
- )
52
- .unwrap();
53
-
54
- let end_cfg = dir.path().join("end.yml");
55
- fs::write(
56
- &end_cfg,
57
- "rules:\n document-start: disable\n new-line-at-end-of-file: disable\n empty-lines:\n max: 5\n max-start: 5\n max-end: 1\n",
58
- )
59
- .unwrap();
60
-
61
- let cases = vec![
62
- Case {
63
- label: "interior-error",
64
- config: interior_cfg.clone(),
65
- target: interior_file.clone(),
66
- expected_exit: 1,
67
- },
68
- Case {
69
- label: "interior-warning",
70
- config: warning_cfg.clone(),
71
- target: interior_file,
72
- expected_exit: 0,
73
- },
74
- Case {
75
- label: "start-error",
76
- config: start_cfg.clone(),
77
- target: start_file,
78
- expected_exit: 1,
79
- },
80
- Case {
81
- label: "end-error",
82
- config: end_cfg.clone(),
83
- target: end_file,
84
- expected_exit: 1,
85
- },
86
- ];
87
-
88
- let exe = env!("CARGO_BIN_EXE_ryl");
89
-
90
- for scenario in SCENARIOS {
91
- for case in &cases {
92
- let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
93
- ryl_cmd.arg("-c").arg(&case.config).arg(&case.target);
94
- let (ryl_code, ryl_output) = capture_with_env(ryl_cmd, scenario.envs);
95
-
96
- let mut yam_cmd = build_yamllint_command(scenario.yam_format);
97
- yam_cmd.arg("-c").arg(&case.config).arg(&case.target);
98
- let (yam_code, yam_output) = capture_with_env(yam_cmd, scenario.envs);
99
-
100
- assert_eq!(
101
- ryl_code, case.expected_exit,
102
- "ryl exit mismatch ({}/{})",
103
- scenario.label, case.label
104
- );
105
- assert_eq!(
106
- yam_code, case.expected_exit,
107
- "yamllint exit mismatch ({}/{})",
108
- scenario.label, case.label
109
- );
110
- assert_eq!(
111
- ryl_output, yam_output,
112
- "diagnostics mismatch ({}/{})",
113
- scenario.label, case.label
114
- );
115
- }
116
- }
117
- }
@@ -1,179 +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 empty_values_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let violations = dir.path().join("violations.yaml");
20
- fs::write(
21
- &violations,
22
- "block:\n missing:\nflow: { missing: }\nseq:\n -\n",
23
- )
24
- .unwrap();
25
-
26
- let clean = dir.path().join("clean.yaml");
27
- fs::write(
28
- &clean,
29
- "block:\n present: value\nflow: { present: value }\nseq:\n - value\n",
30
- )
31
- .unwrap();
32
-
33
- let all_cfg = dir.path().join("empty-all.yml");
34
- fs::write(
35
- &all_cfg,
36
- "rules:\n document-start: disable\n empty-values: enable\n",
37
- )
38
- .unwrap();
39
-
40
- let block_cfg = dir.path().join("empty-block.yml");
41
- fs::write(
42
- &block_cfg,
43
- "rules:\n document-start: disable\n empty-values:\n forbid-in-block-mappings: true\n forbid-in-flow-mappings: false\n forbid-in-block-sequences: false\n",
44
- )
45
- .unwrap();
46
-
47
- let flow_cfg = dir.path().join("empty-flow.yml");
48
- fs::write(
49
- &flow_cfg,
50
- "rules:\n document-start: disable\n empty-values:\n forbid-in-block-mappings: false\n forbid-in-flow-mappings: true\n forbid-in-block-sequences: false\n",
51
- )
52
- .unwrap();
53
-
54
- let seq_cfg = dir.path().join("empty-seq.yml");
55
- fs::write(
56
- &seq_cfg,
57
- "rules:\n document-start: disable\n empty-values:\n forbid-in-block-mappings: false\n forbid-in-flow-mappings: false\n forbid-in-block-sequences: true\n",
58
- )
59
- .unwrap();
60
-
61
- let none_cfg = dir.path().join("empty-none.yml");
62
- fs::write(
63
- &none_cfg,
64
- "rules:\n document-start: disable\n empty-values:\n forbid-in-block-mappings: false\n forbid-in-flow-mappings: false\n forbid-in-block-sequences: false\n",
65
- )
66
- .unwrap();
67
-
68
- let exe = env!("CARGO_BIN_EXE_ryl");
69
-
70
- for scenario in SCENARIOS {
71
- let mut ryl_all = build_ryl_command(exe, scenario.ryl_format);
72
- ryl_all.arg("-c").arg(&all_cfg).arg(&violations);
73
- let (ryl_all_code, ryl_all_msg) = capture_with_env(ryl_all, scenario.envs);
74
-
75
- let mut yam_all = build_yamllint_command(scenario.yam_format);
76
- yam_all.arg("-c").arg(&all_cfg).arg(&violations);
77
- let (yam_all_code, yam_all_msg) = capture_with_env(yam_all, scenario.envs);
78
-
79
- assert_eq!(ryl_all_code, 1, "ryl all exit ({})", scenario.label);
80
- assert_eq!(yam_all_code, 1, "yamllint all exit ({})", scenario.label);
81
- assert_eq!(
82
- ryl_all_msg, yam_all_msg,
83
- "all diagnostics mismatch ({})",
84
- scenario.label
85
- );
86
-
87
- let mut ryl_block = build_ryl_command(exe, scenario.ryl_format);
88
- ryl_block.arg("-c").arg(&block_cfg).arg(&violations);
89
- let (ryl_block_code, ryl_block_msg) =
90
- capture_with_env(ryl_block, scenario.envs);
91
-
92
- let mut yam_block = build_yamllint_command(scenario.yam_format);
93
- yam_block.arg("-c").arg(&block_cfg).arg(&violations);
94
- let (yam_block_code, yam_block_msg) =
95
- capture_with_env(yam_block, scenario.envs);
96
-
97
- assert_eq!(ryl_block_code, 1, "ryl block exit ({})", scenario.label);
98
- assert_eq!(
99
- yam_block_code, 1,
100
- "yamllint block exit ({})",
101
- scenario.label
102
- );
103
- assert_eq!(
104
- ryl_block_msg, yam_block_msg,
105
- "block diagnostics mismatch ({})",
106
- scenario.label
107
- );
108
-
109
- let mut ryl_flow = build_ryl_command(exe, scenario.ryl_format);
110
- ryl_flow.arg("-c").arg(&flow_cfg).arg(&violations);
111
- let (ryl_flow_code, ryl_flow_msg) = capture_with_env(ryl_flow, scenario.envs);
112
-
113
- let mut yam_flow = build_yamllint_command(scenario.yam_format);
114
- yam_flow.arg("-c").arg(&flow_cfg).arg(&violations);
115
- let (yam_flow_code, yam_flow_msg) = capture_with_env(yam_flow, scenario.envs);
116
-
117
- assert_eq!(ryl_flow_code, 1, "ryl flow exit ({})", scenario.label);
118
- assert_eq!(yam_flow_code, 1, "yamllint flow exit ({})", scenario.label);
119
- assert_eq!(
120
- ryl_flow_msg, yam_flow_msg,
121
- "flow diagnostics mismatch ({})",
122
- scenario.label
123
- );
124
-
125
- let mut ryl_seq = build_ryl_command(exe, scenario.ryl_format);
126
- ryl_seq.arg("-c").arg(&seq_cfg).arg(&violations);
127
- let (ryl_seq_code, ryl_seq_msg) = capture_with_env(ryl_seq, scenario.envs);
128
-
129
- let mut yam_seq = build_yamllint_command(scenario.yam_format);
130
- yam_seq.arg("-c").arg(&seq_cfg).arg(&violations);
131
- let (yam_seq_code, yam_seq_msg) = capture_with_env(yam_seq, scenario.envs);
132
-
133
- assert_eq!(ryl_seq_code, 1, "ryl seq exit ({})", scenario.label);
134
- assert_eq!(yam_seq_code, 1, "yamllint seq exit ({})", scenario.label);
135
- assert_eq!(
136
- ryl_seq_msg, yam_seq_msg,
137
- "seq diagnostics mismatch ({})",
138
- scenario.label
139
- );
140
-
141
- let mut ryl_none = build_ryl_command(exe, scenario.ryl_format);
142
- ryl_none.arg("-c").arg(&none_cfg).arg(&violations);
143
- let (ryl_none_code, ryl_none_msg) = capture_with_env(ryl_none, scenario.envs);
144
-
145
- let mut yam_none = build_yamllint_command(scenario.yam_format);
146
- yam_none.arg("-c").arg(&none_cfg).arg(&violations);
147
- let (yam_none_code, yam_none_msg) = capture_with_env(yam_none, scenario.envs);
148
-
149
- assert_eq!(ryl_none_code, 0, "ryl none exit ({})", scenario.label);
150
- assert_eq!(yam_none_code, 0, "yamllint none exit ({})", scenario.label);
151
- assert_eq!(
152
- ryl_none_msg, yam_none_msg,
153
- "none diagnostics mismatch ({})",
154
- scenario.label
155
- );
156
-
157
- let mut ryl_clean = build_ryl_command(exe, scenario.ryl_format);
158
- ryl_clean.arg("-c").arg(&all_cfg).arg(&clean);
159
- let (ryl_clean_code, ryl_clean_msg) =
160
- capture_with_env(ryl_clean, scenario.envs);
161
-
162
- let mut yam_clean = build_yamllint_command(scenario.yam_format);
163
- yam_clean.arg("-c").arg(&all_cfg).arg(&clean);
164
- let (yam_clean_code, yam_clean_msg) =
165
- capture_with_env(yam_clean, scenario.envs);
166
-
167
- assert_eq!(ryl_clean_code, 0, "ryl clean exit ({})", scenario.label);
168
- assert_eq!(
169
- yam_clean_code, 0,
170
- "yamllint clean exit ({})",
171
- scenario.label
172
- );
173
- assert_eq!(
174
- ryl_clean_msg, yam_clean_msg,
175
- "clean diagnostics mismatch ({})",
176
- scenario.label
177
- );
178
- }
179
- }
@@ -1,216 +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 float_values_rule_matches_yamllint() {
15
- ensure_yamllint_installed();
16
-
17
- let dir = tempdir().unwrap();
18
-
19
- let violations = dir.path().join("violations.yaml");
20
- fs::write(&violations, "a: .5\nb: 1e2\nc: .nan\nd: .inf\n").unwrap();
21
-
22
- let ok = dir.path().join("ok.yaml");
23
- fs::write(&ok, "a: 0.5\nb: 10.0\nc: 0.0\n").unwrap();
24
-
25
- let default_cfg = dir.path().join("float-default.yml");
26
- fs::write(
27
- &default_cfg,
28
- "rules:\n document-start: disable\n float-values: enable\n",
29
- )
30
- .unwrap();
31
-
32
- let require_cfg = dir.path().join("float-require.yml");
33
- fs::write(
34
- &require_cfg,
35
- "rules:\n document-start: disable\n float-values:\n require-numeral-before-decimal: true\n",
36
- )
37
- .unwrap();
38
-
39
- let scientific_cfg = dir.path().join("float-scientific.yml");
40
- fs::write(
41
- &scientific_cfg,
42
- "rules:\n document-start: disable\n float-values:\n forbid-scientific-notation: true\n",
43
- )
44
- .unwrap();
45
-
46
- let nan_cfg = dir.path().join("float-nan.yml");
47
- fs::write(
48
- &nan_cfg,
49
- "rules:\n document-start: disable\n float-values:\n forbid-nan: true\n",
50
- )
51
- .unwrap();
52
-
53
- let inf_cfg = dir.path().join("float-inf.yml");
54
- fs::write(
55
- &inf_cfg,
56
- "rules:\n document-start: disable\n float-values:\n forbid-inf: true\n",
57
- )
58
- .unwrap();
59
-
60
- let all_cfg = dir.path().join("float-all.yml");
61
- fs::write(
62
- &all_cfg,
63
- "rules:\n document-start: disable\n float-values:\n require-numeral-before-decimal: true\n forbid-scientific-notation: true\n forbid-nan: true\n forbid-inf: true\n",
64
- )
65
- .unwrap();
66
-
67
- let exe = env!("CARGO_BIN_EXE_ryl");
68
-
69
- for scenario in SCENARIOS {
70
- // Default configuration should not flag anything
71
- let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
72
- ryl_default.arg("-c").arg(&default_cfg).arg(&violations);
73
- let (ryl_default_code, ryl_default_msg) =
74
- capture_with_env(ryl_default, scenario.envs);
75
-
76
- let mut yam_default = build_yamllint_command(scenario.yam_format);
77
- yam_default.arg("-c").arg(&default_cfg).arg(&violations);
78
- let (yam_default_code, yam_default_msg) =
79
- capture_with_env(yam_default, scenario.envs);
80
-
81
- assert_eq!(ryl_default_code, 0, "ryl default exit ({})", scenario.label);
82
- assert_eq!(
83
- yam_default_code, 0,
84
- "yamllint default exit ({})",
85
- scenario.label
86
- );
87
- assert_eq!(
88
- ryl_default_msg, yam_default_msg,
89
- "default diagnostics mismatch ({})",
90
- scenario.label
91
- );
92
-
93
- // require-numeral-before-decimal
94
- let mut ryl_require = build_ryl_command(exe, scenario.ryl_format);
95
- ryl_require.arg("-c").arg(&require_cfg).arg(&violations);
96
- let (ryl_require_code, ryl_require_msg) =
97
- capture_with_env(ryl_require, scenario.envs);
98
-
99
- let mut yam_require = build_yamllint_command(scenario.yam_format);
100
- yam_require.arg("-c").arg(&require_cfg).arg(&violations);
101
- let (yam_require_code, yam_require_msg) =
102
- capture_with_env(yam_require, scenario.envs);
103
-
104
- assert_eq!(ryl_require_code, 1, "ryl require exit ({})", scenario.label);
105
- assert_eq!(
106
- yam_require_code, 1,
107
- "yamllint require exit ({})",
108
- scenario.label
109
- );
110
- assert_eq!(
111
- ryl_require_msg, yam_require_msg,
112
- "require diagnostics mismatch ({})",
113
- scenario.label
114
- );
115
-
116
- // forbid-scientific-notation
117
- let mut ryl_scientific = build_ryl_command(exe, scenario.ryl_format);
118
- ryl_scientific
119
- .arg("-c")
120
- .arg(&scientific_cfg)
121
- .arg(&violations);
122
- let (ryl_scientific_code, ryl_scientific_msg) =
123
- capture_with_env(ryl_scientific, scenario.envs);
124
-
125
- let mut yam_scientific = build_yamllint_command(scenario.yam_format);
126
- yam_scientific
127
- .arg("-c")
128
- .arg(&scientific_cfg)
129
- .arg(&violations);
130
- let (yam_scientific_code, yam_scientific_msg) =
131
- capture_with_env(yam_scientific, scenario.envs);
132
-
133
- assert_eq!(
134
- ryl_scientific_code, 1,
135
- "ryl scientific exit ({})",
136
- scenario.label
137
- );
138
- assert_eq!(
139
- yam_scientific_code, 1,
140
- "yamllint scientific exit ({})",
141
- scenario.label
142
- );
143
- assert_eq!(
144
- ryl_scientific_msg, yam_scientific_msg,
145
- "scientific diagnostics mismatch ({})",
146
- scenario.label
147
- );
148
-
149
- // forbid-nan
150
- let mut ryl_nan = build_ryl_command(exe, scenario.ryl_format);
151
- ryl_nan.arg("-c").arg(&nan_cfg).arg(&violations);
152
- let (ryl_nan_code, ryl_nan_msg) = capture_with_env(ryl_nan, scenario.envs);
153
-
154
- let mut yam_nan = build_yamllint_command(scenario.yam_format);
155
- yam_nan.arg("-c").arg(&nan_cfg).arg(&violations);
156
- let (yam_nan_code, yam_nan_msg) = capture_with_env(yam_nan, scenario.envs);
157
-
158
- assert_eq!(ryl_nan_code, 1, "ryl nan exit ({})", scenario.label);
159
- assert_eq!(yam_nan_code, 1, "yamllint nan exit ({})", scenario.label);
160
- assert_eq!(
161
- ryl_nan_msg, yam_nan_msg,
162
- "nan diagnostics mismatch ({})",
163
- scenario.label
164
- );
165
-
166
- // forbid-inf
167
- let mut ryl_inf = build_ryl_command(exe, scenario.ryl_format);
168
- ryl_inf.arg("-c").arg(&inf_cfg).arg(&violations);
169
- let (ryl_inf_code, ryl_inf_msg) = capture_with_env(ryl_inf, scenario.envs);
170
-
171
- let mut yam_inf = build_yamllint_command(scenario.yam_format);
172
- yam_inf.arg("-c").arg(&inf_cfg).arg(&violations);
173
- let (yam_inf_code, yam_inf_msg) = capture_with_env(yam_inf, scenario.envs);
174
-
175
- assert_eq!(ryl_inf_code, 1, "ryl inf exit ({})", scenario.label);
176
- assert_eq!(yam_inf_code, 1, "yamllint inf exit ({})", scenario.label);
177
- assert_eq!(
178
- ryl_inf_msg, yam_inf_msg,
179
- "inf diagnostics mismatch ({})",
180
- scenario.label
181
- );
182
-
183
- // all options enabled, expect four diagnostics, and ok file passes
184
- let mut ryl_all = build_ryl_command(exe, scenario.ryl_format);
185
- ryl_all.arg("-c").arg(&all_cfg).arg(&violations);
186
- let (ryl_all_code, ryl_all_msg) = capture_with_env(ryl_all, scenario.envs);
187
-
188
- let mut yam_all = build_yamllint_command(scenario.yam_format);
189
- yam_all.arg("-c").arg(&all_cfg).arg(&violations);
190
- let (yam_all_code, yam_all_msg) = capture_with_env(yam_all, scenario.envs);
191
-
192
- assert_eq!(ryl_all_code, 1, "ryl all exit ({})", scenario.label);
193
- assert_eq!(yam_all_code, 1, "yamllint all exit ({})", scenario.label);
194
- assert_eq!(
195
- ryl_all_msg, yam_all_msg,
196
- "all diagnostics mismatch ({})",
197
- scenario.label
198
- );
199
-
200
- let mut ryl_ok = build_ryl_command(exe, scenario.ryl_format);
201
- ryl_ok.arg("-c").arg(&all_cfg).arg(&ok);
202
- let (ryl_ok_code, ryl_ok_msg) = capture_with_env(ryl_ok, scenario.envs);
203
-
204
- let mut yam_ok = build_yamllint_command(scenario.yam_format);
205
- yam_ok.arg("-c").arg(&all_cfg).arg(&ok);
206
- let (yam_ok_code, yam_ok_msg) = capture_with_env(yam_ok, scenario.envs);
207
-
208
- assert_eq!(ryl_ok_code, 0, "ryl ok exit ({})", scenario.label);
209
- assert_eq!(yam_ok_code, 0, "yamllint ok exit ({})", scenario.label);
210
- assert_eq!(
211
- ryl_ok_msg, yam_ok_msg,
212
- "ok diagnostics mismatch ({})",
213
- scenario.label
214
- );
215
- }
216
- }