Skip to content

Commit 17be9be

Browse files
Maxence MauryElectreAAS
authored andcommitted
fix: address review feedback for promotion show command
- Change User_warning.emit to User_error.raise when no promotion available - Remove unnecessary Cmdliner.Arg module prefix for 'file' argument - Remove redundant 2>&1 redirections from cram tests Signed-off-by: Maxence Maury <[email protected]>
1 parent f1653ca commit 17be9be

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

bin/promotion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let show_corrected_contents files_to_promote =
4141
let contents = Io.read_file correction_file in
4242
Console.printf "%s" contents)
4343
else
44-
User_warning.emit
44+
User_error.raise
4545
[ Pp.textf
4646
"Corrected file does not exist for %s."
4747
(Diff_promotion.File.source file |> Path.Source.to_string_maybe_quoted)
@@ -139,7 +139,7 @@ module Show = struct
139139

140140
let term =
141141
let+ builder = Common.Builder.term
142-
and+ files = Arg.(value & pos_all Cmdliner.Arg.file [] & info [] ~docv:"FILE") in
142+
and+ files = Arg.(value & pos_all file [] & info [] ~docv:"FILE") in
143143
let common, config = Common.init builder in
144144
let files_to_promote = files_to_promote ~common files in
145145
Scheduler.go_with_rpc_server ~common ~config (fun () ->

test/blackbox-tests/test-cases/promote/promotion-show.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ We create different promotion scenarios to test various behaviors:
7373
When no tests have run yet, there are no corrected files in _build,
7474
so 'show' should return a warning (not an error, as this is informational).
7575
76-
$ dune promotion show a.expected 2>&1
76+
$ dune promotion show a.expected
7777
Warning: Nothing to promote for a.expected.
7878
7979
=== TEST: Generate corrections by running tests ===
8080
Running tests will create .actual files in _build that differ from
8181
the .expected files. Note that only 'diff' and some 'diff?' rules
8282
actually create promotable files.
8383
84-
$ dune runtest 2>&1
84+
$ dune runtest
8585
File "a.expected", line 1, characters 0-0:
8686
Error: Files _build/default/a.expected and _build/default/a.actual differ.
8787
File "b.expected", line 1, characters 0-0:
@@ -125,7 +125,7 @@ This is important for scripting and batch operations where partial
125125
success is better than complete failure.
126126

127127
$ touch nothing-to-promote.txt
128-
$ dune promotion show a.expected nothing-to-promote.txt b.expected 2>&1
128+
$ dune promotion show a.expected nothing-to-promote.txt b.expected
129129
Warning: Nothing to promote for nothing-to-promote.txt.
130130
A actual
131131

@@ -139,7 +139,7 @@ the command fails with a usage error and exit code 1.
139139
This is different from "nothing to promote" - the file must exist
140140
in the filesystem to be checked for promotions.
141141
142-
$ dune promotion show does-not-exist.ml 2>&1
142+
$ dune promotion show does-not-exist.ml
143143
dune: FILE… arguments: no 'does-not-exist.ml' file or directory
144144
Usage: dune promotion show [OPTION]… [FILE]…
145145
Try 'dune promotion show --help' or 'dune --help' for more information.
@@ -173,7 +173,7 @@ always create a promotion entry. This is expected behavior.
173173

174174
$ dune promotion show c.expected > c.shown
175175
Warning: Nothing to promote for c.expected.
176-
$ dune promote c.expected 2>&1
176+
$ dune promote c.expected
177177
Warning: Nothing to promote for c.expected.
178178

179179
Since there was nothing to promote, c.expected remains unchanged
@@ -188,7 +188,7 @@ and the diff shows they're different (original vs unchanged).
188188
The 'show' command is read-only, so files remain available for
189189
promotion after being shown.
190190
191-
$ dune promotion show c.expected 2>&1
191+
$ dune promotion show c.expected
192192
Warning: Nothing to promote for c.expected.
193193
194194
=== TEST: Other files still available ===
@@ -216,7 +216,7 @@ This tests robustness against zero-length file content.
216216
> EOF
217217
218218
$ echo 'not empty' > empty.expected
219-
$ dune runtest 2>&1
219+
$ dune runtest
220220
221221
In this case, 'diff?' doesn't create a promotion entry for the empty file.
222222
@@ -242,7 +242,7 @@ to verify whether 'diff?' creates promotions for such files.
242242
> EOF
243243
244244
$ echo 'old content' > multi.expected
245-
$ dune runtest 2>&1
245+
$ dune runtest
246246
247247
This 'diff?' rule also doesn't create a promotion entry.
248248

0 commit comments

Comments
 (0)