Skip to content
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

Add backtraces to test errors #5771

Merged
merged 2 commits into from Mar 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/builtin_test.cpp
Expand Up @@ -21,6 +21,7 @@
#include "builtin.h"
#include "common.h"
#include "io.h"
#include "parser.h"
#include "wutil.h" // IWYU pragma: keep

using std::unique_ptr;
Expand Down Expand Up @@ -830,6 +831,7 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
argc--;
} else {
streams.err.append(L"[: the last argument must be ']'\n");
builtin_print_error_trailer(parser, streams.err, program_name);
return STATUS_INVALID_ARGS;
}
}
Expand All @@ -848,14 +850,8 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wcstring err;
unique_ptr<expression> expr = test_parser::parse_args(args, err, program_name);
if (!expr) {
#if 0
streams.err.append(L"Oops! test was given args:\n");
for (size_t i=0; i < argc; i++) {
streams.err.append_format(L"\t%ls\n", args.at(i).c_str());
}
streams.err.append_format(L"and returned parse error: %ls\n", err.c_str());
#endif
streams.err.append(err);
builtin_print_error_trailer(parser, streams.err, program_name);
return STATUS_CMD_ERROR;
}

Expand All @@ -864,8 +860,11 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
if (!eval_errors.empty()) {
if (!should_suppress_stderr_for_tests()) {
for (size_t i = 0; i < eval_errors.size(); i++) {
streams.err.append_format(L"\t%ls\n", eval_errors.at(i).c_str());
streams.err.append_format(L"%ls\n", eval_errors.at(i).c_str());
}
// Add a backtrace but not the "see help" message
// because this isn't about passing the wrong options.
streams.err.append(parser.current_line());
}
return STATUS_INVALID_ARGS;
}
Expand Down