Skip to content

Commit

Permalink
Better error reporting in standardized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joajfreitas committed Jan 3, 2025
1 parent ac7382a commit 2f50383
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/fcp_cpp/tests/cc_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,8 @@ def cc_binary(name: str, srcs: List[Source], headers: List[str]) -> None:

r = subprocess.run([Path(tempdirname) / name])
if r.returncode != 0:
print(r.stderr.decode())
if r.stderr is not None:
print(r.stderr.decode())
if r.stdout is not None:
print(r.stdout.decode())
raise ValueError("Running executable failed")
10 changes: 10 additions & 0 deletions plugins/fcp_cpp/tests/test_standard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def access_field(fcp: FcpV2, xpath: str) -> str:


test_template = """
#include <iostream>
#include "fcp.h"
#include "utest.h"
Expand All @@ -126,6 +127,15 @@ def access_field(fcp: FcpV2, xpath: str) -> str:
std::vector<std::uint8_t> expected { {%- for value in test["encoded"] -%} {{value}} {%- if not loop.last -%},{%- endif -%}{%- endfor -%} };
EXPECT_TRUE(encoded == expected);
if (encoded != expected) {
for (size_t i = 0; i < encoded.size(); i++) {
std::cout << "encoded[" << i << "] = " << (int)encoded[i] << std::endl;
}
for (size_t i = 0; i < expected.size(); i++) {
std::cout << "expected[" << i << "] = " << (int)expected[i] << std::endl;
}
}
}
{% endfor %}
"""
Expand Down

0 comments on commit 2f50383

Please sign in to comment.