Skip to content

Adopt Rust log and console_log to offer finer-grained control over test output #25

@evomimic

Description

@evomimic

Problem Statement

While debugging test logic or when investigating a failure of a test case, it is often useful to insert println's to write out various info as a test progresses. As the number of test cases grows, the amount of output from all these test cases can be overwhelming. But going through and commenting out println's when we don't want their output and then uncommenting them can be tedious.

Proposal

Offer control at the test case level over the quantity of information that test case will produce, without having to comment or uncomment printlns. This is made possible by allowing fixtures to individually set a message_threshold that is passed as input into the test function (via the case inputs). Within test functions, configure the Rust logger with the message_threshold passed in via the test case and replace println! calls with calls on a the Rust log macros using the console_log implementation.

"A log request consists of a target, a level, and a body. A target is a string which defaults to the module path of the location of the log request, though that default may be overridden. Logger implementations typically use the target to filter requests based on some user configuration."

Examples:

Current:

     println!("******* STARTING TESTS WITH {h_count} HOLON DESCRIPTORS ***************************");
     println!("****** Starting create/get test for the following HolonDescriptor");
     println!("{:#?}", descriptor);
     println!("Creating {name} with {p_count} properties");

Proposed:

     info!("******* STARTING TESTS WITH {h_count} HOLON DESCRIPTORS ***************************");
     trace!("****** Starting create/get test for the following HolonDescriptor");
    debug!("{:#?}", descriptor);
     debug!("Creating {name} with {p_count} properties");

NOTE: Available message macros are, in order from highest to lowest message level:
error!,
warn!,
info!,
debug! and
trace!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions