Opened 4 weeks ago

Last modified 4 weeks ago

#30968 new enhancement

Refactor unit test asserts so they log context

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: refactor, technical-debt, ipv6, tor-dns, sponsor-31-maybe
Cc: gaba, catalyst Actual Points:
Parent ID: Points: 2
Reviewer: Sponsor:

Description

In #30721, I created some complex macros to preserve line numbers when the unit tests fail.

We could refactor these macros into functions, if the tiny test assertions supported context.

catalyst suggests allowing file and line numbers (and functions?):

I think I see that the problem is buried in the TT_DECLARE() macro in tinytest_macros.h. I think it's possible to work around it, but it might be nontrivial. (Rough sketch: redefine TT_DECLARE() in helper functions to read file and line info from function parameters, and make file and line numbers explicit parameters to helper functions.)

I suggest allowing a format string, which could also print the data that we're testing. (For the tor_addr_port_lookup() tests, the best context is the address string.)

Child Tickets

Change History (2)

comment:1 Changed 4 weeks ago by teor

Keywords: sponsor-31-maybe added

gaba, I don't know if we want to do this refactor as part of sponsor 31.

comment:2 Changed 4 weeks ago by catalyst

Cc: catalyst added
Note: See TracTickets for help on using tickets.