Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Jan 23, 2026

High Level Overview of Change

This PR uses std::source_location to add to test Env error output the file and line location of the call that triggered the failed transaction.

There is no change to the source code.

Context of Change

Improved test logging, easier debugging

Type of Change

  • New feature (non-breaking change which adds functionality)

API Impact

N/A

Test Plan

I used this commit to help me debug a test failure in another branch.

Copilot AI review requested due to automatic review settings January 23, 2026 21:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances test debugging by adding source location information (file and line number) to test environment error messages using C++20's std::source_location. When test transactions fail, the error output will now include the exact file and line where the test was invoked.

Changes:

  • Adds std::source_location parameters to submit(), sign_and_submit(), and postconditions() methods to capture call site location
  • Introduces WithSourceLoc wrapper struct to enable implicit conversion with source location capture for variadic template methods
  • Updates error messages to include file and line information in the format (filename:line)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/test/jtx/Env.h Adds WithSourceLoc wrapper struct and updates method signatures to accept source location parameters
src/test/jtx/impl/Env.cpp Implements source location threading through submission methods and formats location info in error messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +79
struct WithSourceLoc
{
std::variant<Json::Value, JTx> value;
std::source_location loc;

// Non-explicit constructors allow implicit conversion.
// The default argument for loc is evaluated at the call site.
WithSourceLoc(
Json::Value v,
std::source_location l = std::source_location::current())
: value(std::move(v)), loc(l)
{
}

WithSourceLoc(
JTx v,
std::source_location l = std::source_location::current())
: value(std::move(v)), loc(l)
{
}
};
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WithSourceLoc struct lacks documentation explaining why it exists and how it should be used. While the existing comment explains the mechanism, it would benefit from additional documentation describing the intended usage pattern and when developers should use this wrapper.

Copilot uses AI. Check for mistakes.
Comment on lines +437 to +438
auto const file =
std::string("(") + loc.file_name() + ":" + to_string(loc.line()) + ")";
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file location formatting is duplicated in the variable construction. Consider extracting this into a helper function or formatting it inline where used, as it's only referenced twice in close proximity.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.4%. Comparing base (778da95) to head (610c3ea).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6276     +/-   ##
=========================================
- Coverage     79.4%   79.4%   -0.0%     
=========================================
  Files          839     839             
  Lines        71619   71619             
  Branches      8236    8236             
=========================================
- Hits         56850   56849      -1     
- Misses       14769   14770      +1     

see 1 file with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant