Skip to content

Conversation

Riyuzak2510
Copy link

Adding Unscoped Capture Logger as a part of #2954

Description

Added Unscoped Capture Logger Feature as required to print details related to Capture

  • Added New Macro UNSCOPED_CAPTURE

GitHub Issues

Closes #2954

@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from b6d1042 to d34e490 Compare July 30, 2025 06:10
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.95%. Comparing base (3e82ef9) to head (5abeb26).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3010      +/-   ##
==========================================
+ Coverage   90.92%   90.95%   +0.03%     
==========================================
  Files         201      201              
  Lines        8653     8659       +6     
==========================================
+ Hits         7867     7875       +8     
+ Misses        786      784       -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch 6 times, most recently from 4e18ef2 to 98c9b6f Compare August 6, 2025 16:18
@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from c3d0075 to abfdfcf Compare August 6, 2025 17:53
Comment on lines 102 to 104
std::vector<MessageInfo> getMessageDetails() const {
return m_messages;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is not used anymore. For next time, this shouldn't be returning the vector by value, but by reference, and be ref-qualified if needed.

Copy link
Author

Choose a reason for hiding this comment

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

Removed it

Comment on lines 76 to 88
void captureUnscopedValue( size_t index, std::string const& value );

template<typename T>
void captureUnscopedValues( size_t index, T const& value ) {
captureUnscopedValue( index, Catch::Detail::stringify( value ) );
}

template<typename T, typename... Ts>
void captureUnscopedValues( size_t index, T const& value, Ts const&... values ) {
captureUnscopedValue( index, Catch::Detail::stringify(value) );
captureUnscopedValues( index+1, values... );
}

Copy link
Member

Choose a reason for hiding this comment

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

Let's not duplicate these, and instead add bool isScoped parameter to the constructor of Capturer, which will be kept to decide whether captureValue should create scoped or unscoped msg.

Copy link
Author

Choose a reason for hiding this comment

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

yeah modified this

getResultCapture().emplaceUnscopedMessage(Catch::MessageBuilder(
m_messages[index].macroName,
m_messages[index].lineInfo,
m_messages[index].type) << m_messages[index].message);
Copy link
Member

Choose a reason for hiding this comment

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

No need to copy the value into message first and then write it into the msg builder stream.

Copy link
Author

Choose a reason for hiding this comment

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

done

#define UNSCOPED_INFO( msg ) (void)(0)
#define WARN( msg ) (void)(0)
#define CAPTURE( ... ) (void)(0)
#define UNSCOPED_CAPTURE( ... ) (void)(0)
Copy link
Member

Choose a reason for hiding this comment

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

Please re-align the empty definitions for the whole block. (And same for the one around line 150)

Copy link
Author

Choose a reason for hiding this comment

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

done

@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from 466e345 to d1ede1a Compare August 13, 2025 08:17
@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from d1ede1a to 7c551dd Compare August 13, 2025 08:55
@Riyuzak2510
Copy link
Author

@horenmar feel free to take a look

@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from 7c551dd to 9f4c665 Compare August 13, 2025 09:01
@Riyuzak2510 Riyuzak2510 requested a review from horenmar August 13, 2025 09:04
@Riyuzak2510 Riyuzak2510 force-pushed the UNSCOPED_CAPTURE_LOGGER branch from 9f4c665 to 5abeb26 Compare August 13, 2025 16:39
std::vector<MessageInfo> m_messages;
IResultCapture& m_resultCapture;
size_t m_captured = 0;
bool isScoped;
Copy link
Member

Choose a reason for hiding this comment

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

Take a second look at how the other class variables are named.

m_resultCapture.pushScopedMessage( m_messages[index] );
m_captured++;
if(isScoped){
assert( index < m_messages.size() );
Copy link
Member

Choose a reason for hiding this comment

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

The assert should live at the start of the function, both branches access m_messages[index].

Comment on lines +120 to +122
if(index == m_messages.size() - 1){
m_messages.clear();
}
Copy link
Member

Choose a reason for hiding this comment

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

No need to clear this here, instead check in destructor whether m_isScoped is true and change it accordingly.

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.

UNSCOPED_CAPTURE
2 participants