writer: check that parsed messages can be reformatted verbatim#187
writer: check that parsed messages can be reformatted verbatim#187emersion merged 1 commit intoemersion:masterfrom
Conversation
emersion
left a comment
There was a problem hiding this comment.
Could the original message be reduced to the minimum reproducer?
| orig, _ := os.CreateTemp(os.TempDir(), "go-message-orig-*.txt") | ||
| after, _ := os.CreateTemp(os.TempDir(), "go-message-after-*.txt") | ||
| defer os.Remove(orig.Name()) | ||
| defer os.Remove(after.Name()) | ||
| orig.WriteString(original) | ||
| orig.Close() | ||
| after.Write(buf.Bytes()) | ||
| after.Close() | ||
|
|
||
| var stdout bytes.Buffer | ||
| cmd := exec.Command("diff", "-u", orig.Name(), after.Name()) | ||
| cmd.Stdout = &stdout | ||
| cmd.Run() | ||
| t.Fatalf("reformatted message differs:\n%s", stdout.String()) |
There was a problem hiding this comment.
Hm, not a fan of shelling out to diff. Even if that makes reading the difference more difficult, can we just print both strings instead?
There was a problem hiding this comment.
yes, it was to make spotting the differences easier, but I guess you can instrument the test later to debug it more.
The message needs to be sufficiently long to trigger the issue. I'll try to scrape off the excess as much as possible. |
|
Probably at least the header could be shortened quite a bit? |
fa00e15 to
2cfbf4b
Compare
Without the recent change of line wrapper implementation, this test is
failing. There seem to be line breaks inserted in the middle of the
body:
```diff
--- /tmp/go-message-orig-194495186.txt
+++ /tmp/go-message-after-83245617.txt
@@ -37,7 +37,8 @@
if c.editor == nil {
return
}
-@@ -1205,7 +1213,7 @@ func (c *Composer) termClosed(err error) {
+@@ -1205,7 +1
+213,7 @@ func (c *Composer) termClosed(err error) {
PushError("Failed to reopen email file: " + e.Error())
}
editor := c.editor
@@ -70,7 +71,8 @@
+ PushError(err.Error())
+ })
}
- return
+ return
+
}
--
2.47.1
```
Link: emersion@c2ff70fd20da09d40ba
Link: emersion@6a718fa6214f9f35d33
Signed-off-by: Robin Jarry <robin@jarry.cc>
|
Ooops, forgot to remove the reverts to check that the test was indeed failing: |
2cfbf4b to
c1b1b45
Compare
Without the recent change of line wrapper implementation, this test is failing with the following error:
Link: c2ff70fd20da09d40ba
Link: 6a718fa6214f9f35d33