-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
address failing addTrace test #3783
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
I tried to fix this, but only got so far as reproducing issues on linux and making some cleanups: diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index a4ee7afc2..89256b667 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -353,15 +353,16 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show
out << ANSI_BLUE << std::string(lw, '-') << tracetitle << std::string(rw, '-') << ANSI_NORMAL;
- for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter)
+ for (auto trace : einfo.traces)
{
- try {
- out << std::endl << prefix;
- out << ANSI_BLUE << "trace: " << ANSI_NORMAL << iter->hint.str();
+ out << std::endl << prefix;
+ out << ANSI_BLUE << "trace: " << ANSI_NORMAL << trace.hint.str();
+
+ nl = true;
- nl = true;
- if (*iter->pos) {
- auto pos = iter->pos.value();
+ if (trace.pos) {
+ auto pos = *trace.pos;
+ if (pos) {
out << std::endl << prefix;
printAtPos(prefix, pos, out);
@@ -373,8 +374,8 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show
out << std::endl << prefix;
}
}
- } catch(const std::bad_optional_access& e) {
- out << iter->hint.str() << std::endl;
+ } else {
+ out << trace.hint.str() << std::endl;
}
}
} I couldn't figure out how to change the code to make the test pass, and frankly I am confused by a few things:
|
I'm not seeing macOS issues, but I do see a failure on i686-linux: https://hydra.nixos.org/build/123569347 |
@edolstra That is the same error. I think it's somewhat non-deterministic but architecture agnostic. |
Re the newline at the beginning, initially the code was written with newlines at the end, but the messages ultimately get printed with the assumption that they won't end with a newline, like other messages in the code base. My initial try ended up with extra blank lines as a result. The choice was either make this code without a terminating newline, or change everything else to have them.
You're right, that's an oversight on my part. I removed extra print and got rid of the exception based approach for good measure. |
Well its 2 for 2. Maybe this will fix it? I don't know how to know for sure. |
@bburdette Ah OK, that makes sense. Perhaps we can fix it be separating the thrown vs final rendered format strings a bit (something I was thinking of doing anyways) but that is definitely a good bit extra work. This fix looks good! |
this PR is just so I can prompt macos rebuilds and try to fix my failing addTrace.showTracesWithShowTrace test!