Skip to content

Commit

Permalink
cmd/cue: use fmt --check in the fmt_multi testscript
Browse files Browse the repository at this point in the history
I recently left a TODO there to use a future "check" or "diff" mode
so that we would no longer have to back up and restore files
to see that running fmt in two different ways gives the same result.
Now that --check is a feature, we can use it directly.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I160bd0f9e54f12e4b3d3661b0c5beeeba9c293af
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1190094
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
  • Loading branch information
mvdan committed Apr 26, 2024
1 parent f254cc3 commit 68cd040
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions cmd/cue/cmd/testdata/script/fmt_multi.txtar
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# TODO(mvdan): once we have a "list" or "diff" fmt flag,
# we can reuse the same files without worrying about modifying in-place.
mkdir originals
cp x.cue star.cue y.cue yb.cue originals/

exec cue fmt .
cmp x.cue out/x.cue
cmp star.cue out/star-cue
cmp y.cue out/y-cue
cmp yb.cue out/yb-cue

cp originals/x.cue originals/star.cue originals/y.cue originals/yb.cue .

exec cue fmt x.cue star.cue y.cue yb.cue
cmp x.cue out/x.cue
cmp star.cue out/star-cue
cmp y.cue out/y-cue
cmp yb.cue out/yb-cue
! exec cue fmt --check .
cmp stdout stdout.golden

! exec cue fmt --check x.cue star.cue y.cue yb.cue
cmp stdout stdout.golden
-- stdout.golden --
star.cue
x.cue
y.cue
yb.cue
-- x.cue --
// header

Expand Down

0 comments on commit 68cd040

Please sign in to comment.