mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-01 17:03:19 +00:00
log: add -expect types prefix-log, prefix-warning, prefix-error
This commit is contained in:
parent
67f8de54dc
commit
41107e5473
3 changed files with 63 additions and 36 deletions
|
@ -60,6 +60,8 @@ struct LoggerPass : public Pass {
|
|||
log(" -expect <type> <regex> <expected_count>\n");
|
||||
log(" expect log, warning or error to appear. matched errors will terminate\n");
|
||||
log(" with exit code 0.\n");
|
||||
log(" Types prefix-log, prefix-warning and prefix-error match the entire\n");
|
||||
log(" logged string, including filename if present.\n");
|
||||
log("\n");
|
||||
log(" -expect-no-warnings\n");
|
||||
log(" gives error in case there is at least one warning that is not expected.\n");
|
||||
|
@ -151,26 +153,33 @@ struct LoggerPass : public Pass {
|
|||
}
|
||||
if (args[argidx] == "-expect" && argidx+3 < args.size()) {
|
||||
std::string type = args[++argidx];
|
||||
if (type!="error" && type!="warning" && type!="log")
|
||||
if (type!="error" && type!="warning" && type!="log"
|
||||
&& type!="prefix-error" && type!="prefix-warning" && type!="prefix-log")
|
||||
log_cmd_error("Expect command require type to be 'log', 'warning' or 'error' !\n");
|
||||
if (type=="error" && log_expect_error.size()>0)
|
||||
if ((type=="error" || type=="prefix-error") && log_expect_error.size()>0)
|
||||
log_cmd_error("Only single error message can be expected !\n");
|
||||
std::string pattern = args[++argidx];
|
||||
if (pattern.front() == '\"' && pattern.back() == '\"') pattern = pattern.substr(1, pattern.size() - 2);
|
||||
if (pattern.front() == '\"' && pattern.back() == '\"') pattern = pattern.substr(1, pattern.size() - 2);
|
||||
int count = atoi(args[++argidx].c_str());
|
||||
if (count<=0)
|
||||
log_cmd_error("Number of expected messages must be higher then 0 !\n");
|
||||
if (type=="error" && count!=1)
|
||||
if ((type=="error" || type=="prefix-error") && count!=1)
|
||||
log_cmd_error("Expected error message occurrences must be 1 !\n");
|
||||
log("Added regex '%s' to expected %s messages list.\n",
|
||||
pattern.c_str(), type.c_str());
|
||||
try {
|
||||
if (type == "error")
|
||||
log_expect_error[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else if (type == "prefix-error")
|
||||
log_expect_prefix_error[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else if (type == "warning")
|
||||
log_expect_warning[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else if (type == "prefix-warning")
|
||||
log_expect_prefix_warning[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else if (type == "log")
|
||||
log_expect_log[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else if (type == "prefix-log")
|
||||
log_expect_prefix_log[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
|
||||
else log_abort();
|
||||
}
|
||||
catch (const std::regex_error& e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue