Fix tests on systems with a non-master git defaultBranch #1

Open
zebreus wants to merge 140 commits from fix-tests-without-master into main
2 changed files with 15 additions and 7 deletions
Showing only changes of commit a510d17484 - Show all commits

View file

@ -1,4 +1,9 @@
#include "fmt.hh" // IWYU pragma: keep #include "fmt.hh" // IWYU pragma: keep
// Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace.
#if __APPLE__ || __FreeBSD__
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#endif
#include <boost/stacktrace/stacktrace.hpp>
template class boost::basic_format<char>; template class boost::basic_format<char>;
@ -11,4 +16,9 @@ template HintFmt::HintFmt(const std::string &, const uint64_t &, const char * co
HintFmt::HintFmt(const std::string & literal) : HintFmt("%s", Uncolored(literal)) {} HintFmt::HintFmt(const std::string & literal) : HintFmt("%s", Uncolored(literal)) {}
void printStackTrace()
{
std::cerr << boost::stacktrace::stacktrace() << std::endl;
}
} }

View file

@ -4,11 +4,6 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <boost/format.hpp> #include <boost/format.hpp>
// Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace.
#if __APPLE__ || __FreeBSD__
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#endif
#include <boost/stacktrace.hpp>
#include "ansicolor.hh" #include "ansicolor.hh"
// Explicit instantiation in fmt.cc // Explicit instantiation in fmt.cc
@ -16,6 +11,9 @@ extern template class boost::basic_format<char>;
namespace nix { namespace nix {
/** Prints a C++ stack trace to stderr using boost stacktrace */
void printStackTrace();
/** /**
* Values wrapped in this struct are printed in magenta. * Values wrapped in this struct are printed in magenta.
* *
@ -176,14 +174,14 @@ public:
std::cerr << "HintFmt received incorrect number of format args. Original format string: '"; std::cerr << "HintFmt received incorrect number of format args. Original format string: '";
std::cerr << format << "'; number of arguments: " << sizeof...(args) << "\n"; std::cerr << format << "'; number of arguments: " << sizeof...(args) << "\n";
// And regardless of the coredump give me a damn stacktrace. // And regardless of the coredump give me a damn stacktrace.
std::cerr << boost::stacktrace::stacktrace() << std::endl; printStackTrace();
abort(); abort();
} }
} catch (boost::io::format_error & ex) { } catch (boost::io::format_error & ex) {
// Same thing, but for anything that happens in the member initializers. // Same thing, but for anything that happens in the member initializers.
std::cerr << "HintFmt received incorrect format string. Original format string: '"; std::cerr << "HintFmt received incorrect format string. Original format string: '";
std::cerr << format << "'; number of arguments: " << sizeof...(args) << "\n"; std::cerr << format << "'; number of arguments: " << sizeof...(args) << "\n";
std::cerr << boost::stacktrace::stacktrace() << std::endl; printStackTrace();
abort(); abort();
} }