-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add insta-based snapshot tests that cover side-by-side format
I'm going to fix inline diff issue #704, and found that the inline format isn't covered by CLI tests. I could duplicate compare_all.sh to test various formats, but it's uneasy to review that a new formatting is better than the previous version. I think snapshot testing will help guarantee the output quality without increasing maintenance burden too much. If we like the idea, maybe we can migrate some of compare_all.sh tests to the insta-based ones. Note that this will add ~10sec to "cargo test" runs.
- Loading branch information
Showing
86 changed files
with
1,982 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ flamegraph.svg | |
.idea | ||
|
||
sample_files/compare.result | ||
tests/snapshots/*.snap.new | ||
|
||
notes.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/snapshots/cli__samples_side_by_side@Session_1.kt.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/Session_1.kt | ||
--- | ||
[1m[93msample_files/Session_2.kt[39m[0m[2m --- 1/2 --- Kotlin[0m | ||
[2m 96 [0m [94;3m/**[0m [2m 96 [0m [94;3m/**[0m | ||
[2m 97 [0m[94;3m * The session's photo URL.[0m [2m 97 [0m[94;3m * The session's photo URL.[0m | ||
[2m 98 [0m[94;3m */[0m [2m 98 [0m[94;3m */[0m | ||
[91;1m 99 [0m [1mval[0m photoUrl: [91mString?[0m, [92;1m 99 [0m [1mval[0m photoUrl: [92;1mString[0m, | ||
[2m100 [0m [2m100 [0m | ||
[2m101 [0m [94;3m/**[0m [2m101 [0m [94;3m/**[0m | ||
[2m102 [0m[94;3m * IDs of the sessions related to this session.[0m [2m102 [0m[94;3m * IDs of the sessions related to this session.[0m | ||
[1msample_files/Session_2.kt[0m[2m --- 2/2 --- Kotlin[0m | ||
[2m114 [0m return startTime [1m<=[0m now [1m&&[0m endTime [1m>=[0m now [2m114 [0m return startTime [1m<=[0m now [1m&&[0m endTime [1m>=[0m now | ||
[2m115 [0m } [2m115 [0m } | ||
[2m... [0m [92;1m116 [0m | ||
[2m... [0m [92;1m117 [0m [92;1mval[0m [92mhasPhoto[0m [92minline[0m [92mget[0m[92;1m([0m[92;1m)[0m [92;1m=[0m [92mphotoUrl[0m[92m.[0m[92misNotEmpty[0m[92;1m([0m[92;1m)[0m | ||
[2m116 [0m [2m118 [0m | ||
[2m117 [0m [94;3m/**[0m [2m119 [0m [94;3m/**[0m | ||
[2m118 [0m[94;3m * Returns whether the session has a video or not. A session could be l[0m [2m120 [0m[94;3m * Returns whether the session has a video or not. A session could be l[0m | ||
[2m[2m... [0m[0m[94;3mive streaming or have a[0m [2m[2m... [0m[0m[94;3mive streaming or have a[0m | ||
[2m119 [0m[94;3m * recorded session. Both live stream and recorded videos are stored in[0m [2m121 [0m[94;3m * recorded session. Both live stream and recorded videos are stored in[0m | ||
[2m[2m... [0m[0m[94;3m [Session.youTubeUrl].[0m [2m[2m... [0m[0m[94;3m [Session.youTubeUrl].[0m | ||
[2m120 [0m[94;3m */[0m [2m122 [0m[94;3m */[0m | ||
[91;1m121 [0m [91;1mfun[0m hasVideo() [1m=[0m youTubeUrl.isNotEmpty() [92;1m123 [0m [92;1mval[0m hasVideo [92minline[0m [92mget[0m() [1m=[0m youTubeUrl.isNotEmpty() | ||
[2m... [0m [92;1m124 [0m | ||
[2m... [0m [92;1m125 [0m [92;1mval[0m [92mhasPhotoOrVideo[0m [92minline[0m [92mget[0m[92;1m([0m[92;1m)[0m [92;1m=[0m [92mhasPhoto[0m [92;1m||[0m [92mhasVideo[0m | ||
[2m122 [0m [2m126 [0m | ||
[2m123 [0m [94;3m/**[0m [2m127 [0m [94;3m/**[0m | ||
[2m124 [0m[94;3m * The year the session was held.[0m [2m128 [0m[94;3m * The year the session was held.[0m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/ada_1.adb | ||
--- | ||
[1m[93msample_files/ada_2.adb[39m[0m[2m --- Ada[0m | ||
[91;1m1 [0m [1mwith[0m Ada.Text_IO; [91;1muse[0m [91mAda[0m[91m.[0m[91mText_IO[0m[91m;[0m [1mprocedure[0m Hello [1mis[0m [1mbegin[0m Put_Line ([91m"[0m[91mHello[0m [2m1 [0m[1mwith[0m Ada.Text_IO; | ||
[91;1m[2m. [0m[0m[91m [0m[91;1;4mWORLD[0m[91m![0m[91m"[0m); [1mend[0m Hello; [2m[2m. [0m[0m | ||
[2m. [0m [92;1m2 [0m | ||
[2m. [0m [2m3 [0m[1mprocedure[0m Hello [1mis[0m | ||
[2m. [0m [92;1m4 [0m [92;1mpackage[0m [92mTIO[0m [92mrenames[0m [92mAda[0m[92m.[0m[92mText_IO[0m[92m;[0m | ||
[2m. [0m [2m5 [0m[1mbegin[0m | ||
[2m. [0m [92;1m6 [0m [92mTIO[0m[92m.[0mPut_Line ([92m"[0m[92mHello[0m[92m [0m[92;1;4mWorld[0m[92m![0m[92m"[0m); | ||
[2m. [0m [2m7 [0m[1mend[0m Hello; |
9 changes: 9 additions & 0 deletions
9
tests/snapshots/cli__samples_side_by_side@added_line_1.txt.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/added_line_1.txt | ||
--- | ||
[1m[93msample_files/added_line_2.txt[39m[0m[2m --- Text[0m | ||
[2m1 [0m[2m1 [0mpotato | ||
[2m2 [0m[2m2 [0mtomato | ||
[2m [0m[92;1m3 [0m[92;1mlegato[0m |
10 changes: 10 additions & 0 deletions
10
tests/snapshots/cli__samples_side_by_side@align_footer_1.txt.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/align_footer_1.txt | ||
--- | ||
[1m[93msample_files/align_footer_2.txt[39m[0m[2m --- Text[0m | ||
[2m1 [0mbefore [2m1 [0mbefore | ||
[91;1m2 [0m[91m [0m[91;1mfoo[0m[91;1m [0m[91mx[0m [92;1m2 [0m[92m [0m[92mx[0m | ||
[91;1m3 [0m[91;1my[0m [2m. [0m | ||
[2m4 [0mafter [2m3 [0mafter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/apex_1.cls | ||
--- | ||
[1m[93msample_files/apex_2.cls[39m[0m[2m --- Apex[0m | ||
No syntactic changes. |
33 changes: 33 additions & 0 deletions
33
tests/snapshots/cli__samples_side_by_side@bad_combine_1.rs.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/bad_combine_1.rs | ||
--- | ||
[1m[93msample_files/bad_combine_2.rs[39m[0m[2m --- 1/2 --- Rust[0m | ||
[91;1m 1 [0m [2m. [0m | ||
[91;1m 2 [0m[91;1mfn[0m [91mcolumn_widths[0m[91;1m([0m [2m. [0m | ||
[91;1m 3 [0m [91mhunks[0m[91m:[0m [91;1m&[0m[91;1m[[0m[91;1mHunk[0m[91;1m][0m[91m,[0m [2m. [0m | ||
[91;1m 4 [0m [91mlhs_mps[0m[91m:[0m [91;1m&[0m[91;1m[[0m[91;1mMatchedPos[0m[91;1m][0m[91m,[0m [2m. [0m | ||
[91;1m 5 [0m [91mrhs_mps[0m[91m:[0m [91;1m&[0m[91;1m[[0m[91;1mMatchedPos[0m[91;1m][0m[91m,[0m [2m. [0m | ||
[91;1m 6 [0m [91mmax_lhs_src_line[0m[91m:[0m [91;1mLineNumber[0m[91m,[0m [2m. [0m | ||
[91;1m 7 [0m [91mmax_rhs_src_line[0m[91m:[0m [91;1mLineNumber[0m[91m,[0m [2m. [0m | ||
[91;1m 8 [0m[91;1m)[0m [91;1m{[0m [2m. [0m | ||
[91;1m 9 [0m[91;1m}[0m [2m. [0m | ||
[91;1m10 [0m [2m. [0m | ||
[2m11 [0m[1mfn[0m display_line_nums( [2m1 [0m[1mfn[0m display_line_nums( | ||
[2m12 [0m) -> ([1mString[0m, [1mString[0m) { [2m2 [0m) -> ([1mString[0m, [1mString[0m) { | ||
[2m13 [0m [1mlet[0m display_rhs_line_num: [1mString[0m = [1mmatch[0m rhs_line_num { [2m3 [0m [1mlet[0m display_rhs_line_num: [1mString[0m = [1mmatch[0m rhs_line_num { | ||
[2m14 [0m [1mSome[0m(line_num) => { [2m4 [0m [1mSome[0m(line_num) => { | ||
[91;1m15 [0m [1mlet[0m s = format_line_num_padded(line_num, [91mrhs_column_width[0m); [92;1m5 [0m [1mlet[0m s = format_line_num_padded(line_num, [92mwidths[0m[92m.[0m[92mrhs_line_nums[0m); | ||
[2m16 [0m [1mif[0m rhs_lines_with_novel.contains([1m&[0mline_num) { [2m6 [0m [1mif[0m rhs_lines_with_novel.contains([1m&[0mline_num) { | ||
[2m17 [0m s.bright_green().to_string() [2m7 [0m s.bright_green().to_string() | ||
[2m18 [0m } [1melse[0m { [2m8 [0m } [1melse[0m { | ||
|
||
[1msample_files/bad_combine_2.rs[0m[2m --- 2/2 --- Rust[0m | ||
[2m21 [0m } [2m11 [0m } | ||
[2m22 [0m [1mNone[0m => format_missing_line_num( [2m12 [0m [1mNone[0m => format_missing_line_num( | ||
[2m23 [0m prev_rhs_line_num.unwrap_or_else(|| [1m10[0m.into()), [2m13 [0m prev_rhs_line_num.unwrap_or_else(|| [1m10[0m.into()), | ||
[91;1m24 [0m [91mrhs_column_width[0m, [92;1m14 [0m [92mwidths[0m[92m.[0m[92mrhs_line_nums[0m, | ||
[2m25 [0m ), [2m15 [0m ), | ||
[2m26 [0m }; [2m16 [0m }; | ||
[2m27 [0m [2m17 [0m |
7 changes: 7 additions & 0 deletions
7
tests/snapshots/cli__samples_side_by_side@change_outer_1.el.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/change_outer_1.el | ||
--- | ||
[1m[93msample_files/change_outer_2.el[39m[0m[2m --- Emacs Lisp[0m | ||
[91;1m1 [0m[91;1m([0mlhs comma rhs[91;1m)[0m [92;1m1 [0m[92;1m[[0m[92;1m([0mlhs[92;1m)[0m comma rhs[92;1m][0m |
35 changes: 35 additions & 0 deletions
35
tests/snapshots/cli__samples_side_by_side@chinese_1.po.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: stdout | ||
input_file: sample_files/chinese_1.po | ||
--- | ||
[1m[93msample_files/chinese_2.po[39m[0m[2m --- 1/3 --- Text[0m | ||
[2mFile permissions changed from 100755 to 100644.[0m | ||
[2m1 [0m#: ../errors.h:589 [2m1 [0m#: ../errors.h:589 | ||
[2m2 [0m# reorder if possible [2m2 [0m# reorder if possible | ||
[2m3 [0m#, fuzzy, c-format [2m3 [0m#, fuzzy, c-format | ||
[91;1m4 [0m[91mmsgid[0m[91m [0m[91m"[0m[91mE244[0m[91m:[0m[91m [0m[91mIllegal[0m[91m [0m[91m%[0m[91ms[0m[91m [0m[91mname[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91ms[0m[91m\[0m[91m"[0m[91m [0m[91min[0m[91m [0m[91mfont[0m[91m [0m[91mname[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91ms[0m[91m\[0m[91m"[0m[91m"[0m [92;1m4 [0m[92;1m#[0m[92;1m [0m[92mmsgid[0m[92m [0m[92m"[0m[92mE244[0m[92m:[0m[92m [0m[92mIllegal[0m[92m [0m[92m%[0m[92ms[0m[92m [0m[92mname[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92ms[0m[92m\[0m[92m"[0m[92m [0m[92min[0m[92m [0m[92mfont[0m[92m [0m[92mname[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92ms[0m[92m\[0m[92m"[0m[92m"[0m | ||
[91;1m5 [0m[91mmsgstr[0m[91m [0m[91m"[0m[91mE244[0m[91m:[0m[91m [0m[91m字体名[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91m3[0m[91m$[0m[91ms[0m[91m\[0m[91m"[0m[91m [0m[91m中有非法[0m[91m [0m[91m%[0m[91m1[0m[91m$[0m[91ms[0m[91m [0m[91m名称[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91m2[0m[91m$[0m[91ms[0m[91m\[0m[91m"[0m[91m"[0m [92;1m5 [0m[92;1m#[0m[92;1m [0m[92mmsgstr[0m[92m [0m[92m"[0m[92mE244[0m[92m:[0m[92m [0m[92m字体名[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92m3[0m[92m$[0m[92ms[0m[92m\[0m[92m"[0m[92m [0m[92m中有非法[0m[92m [0m[92m%[0m[92m1[0m[92m$[0m[92ms[0m[92m [0m[92m名称[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92m2[0m[92m$[0m[92ms[0m[92m\[0m[92m"[0m[92m"[0m | ||
[2m6 [0m [2m6 [0m | ||
[2m7 [0m#: ../errors.h:591 [2m7 [0m#: ../errors.h:591 | ||
[2m8 [0m#, c-format [2m8 [0m#, c-format | ||
|
||
[1msample_files/chinese_2.po[0m[2m --- 2/3 --- Text[0m | ||
[2m21 [0m#: ../errors.h:788 [2m21 [0m#: ../errors.h:788 | ||
[2m22 [0m# reorder if possible [2m22 [0m# reorder if possible | ||
[2m23 [0m#, fuzzy, c-format [2m23 [0m#, fuzzy, c-format | ||
[91;1m24 [0m[91mmsgid[0m[91m [0m[91m"[0m[91mE316[0m[91m:[0m[91m [0m[91mml_get[0m[91m:[0m[91m [0m[91mCannot[0m[91m [0m[91mfind[0m[91m [0m[91mline[0m[91m [0m[91m%[0m[91mld[0m[91m [0m[91min[0m[91m [0m[91mbuffer[0m[91m [0m[91m%[0m[91md[0m[91m [0m[91m%[0m[91ms[0m[91m"[0m [92;1m24 [0m[92;1m#[0m[92;1m [0m[92mmsgid[0m[92m [0m[92m"[0m[92mE316[0m[92m:[0m[92m [0m[92mml_get[0m[92m:[0m[92m [0m[92mCannot[0m[92m [0m[92mfind[0m[92m [0m[92mline[0m[92m [0m[92m%[0m[92mld[0m[92m [0m[92min[0m[92m [0m[92mbuffer[0m[92m [0m[92m%[0m[92md[0m[92m [0m[92m%[0m[92ms[0m[92m"[0m | ||
[91;1m25 [0m[91mmsgstr[0m[91m [0m[91m"[0m[91mE316[0m[91m:[0m[91m [0m[91mml_get[0m[91m:[0m[91m [0m[91m在缓冲区[0m[91m [0m[91m%[0m[91m2[0m[91m$[0m[91md[0m[91m [0m[91m%[0m[91m3[0m[91m$[0m[91ms[0m[91m [0m[91m中找不到第[0m[91m [0m[91m%[0m[91m1[0m[91m$[0m[91mld[0m[91m [0m[91m行[0m[91m"[0m [92;1m25 [0m[92;1m#[0m[92;1m [0m[92mmsgstr[0m[92m [0m[92m"[0m[92mE316[0m[92m:[0m[92m [0m[92mml_get[0m[92m:[0m[92m [0m[92m在缓冲区[0m[92m [0m[92m%[0m[92m2[0m[92m$[0m[92md[0m[92m [0m[92m%[0m[92m3[0m[92m$[0m[92ms[0m[92m [0m[92m中找不到第[0m[92m [0m[92m%[0m[92m1[0m[92m$[0m[92mld[0m[92m [0m[92m行[0m[92m"[0m | ||
[2m26 [0m [2m26 [0m | ||
[2m27 [0m#: ../errors.h:790 [2m27 [0m#: ../errors.h:790 | ||
[2m28 [0mmsgid "E317: Pointer block id wrong" [2m28 [0mmsgid "E317: Pointer block id wrong" | ||
|
||
[1msample_files/chinese_2.po[0m[2m --- 3/3 --- Text[0m | ||
[2m43 [0m#: ../errors.h:2705 [2m43 [0m#: ../errors.h:2705 | ||
[2m44 [0m# reorder if possible [2m44 [0m# reorder if possible | ||
[2m45 [0m#, fuzzy, c-format [2m45 [0m#, fuzzy, c-format | ||
[91;1m46 [0m[91mmsgid[0m[91m [0m[91m"[0m[91mE1037[0m[91m:[0m[91m [0m[91mCannot[0m[91m [0m[91muse[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91ms[0m[91m\[0m[91m"[0m[91m [0m[91mwith[0m[91m [0m[91m%[0m[91ms[0m[91m"[0m [92;1m46 [0m[92;1m#[0m[92;1m [0m[92mmsgid[0m[92m [0m[92m"[0m[92mE1037[0m[92m:[0m[92m [0m[92mCannot[0m[92m [0m[92muse[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92ms[0m[92m\[0m[92m"[0m[92m [0m[92mwith[0m[92m [0m[92m%[0m[92ms[0m[92m"[0m | ||
[91;1m47 [0m[91mmsgstr[0m[91m [0m[91m"[0m[91mE1037[0m[91m:[0m[91m [0m[91m不能对[0m[91m [0m[91m%[0m[91m2[0m[91m$[0m[91ms[0m[91m [0m[91m使用[0m[91m [0m[91m\[0m[91m"[0m[91m%[0m[91m1[0m[91m$[0m[91ms[0m[91m\[0m[91m"[0m[91m"[0m [92;1m47 [0m[92;1m#[0m[92;1m [0m[92mmsgstr[0m[92m [0m[92m"[0m[92mE1037[0m[92m:[0m[92m [0m[92m不能对[0m[92m [0m[92m%[0m[92m2[0m[92m$[0m[92ms[0m[92m [0m[92m使用[0m[92m [0m[92m\[0m[92m"[0m[92m%[0m[92m1[0m[92m$[0m[92ms[0m[92m\[0m[92m"[0m[92m"[0m | ||
[2m48 [0m [2m48 [0m | ||
[2m49 [0m#: ../errors.h:2707 [2m49 [0m#: ../errors.h:2707 | ||
[2m50 [0mmsgid "E1038: \"vim9script\" can only be used in a script" [2m50 [0mmsgid "E1038: \"vim9script\" can only be used in a script" |
Oops, something went wrong.