-
Notifications
You must be signed in to change notification settings - Fork 122
writer: check that parsed messages can be reformatted verbatim #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
emersion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the original message be reduced to the minimum reproducer?
writer_test.go
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
emersion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Without the recent change of line wrapper implementation, this test is failing with the following error:
Link: c2ff70fd20da09d40ba
Link: 6a718fa6214f9f35d33