Feature request: CTEST - Individual log files per test

Hey there,

Summary:
CTest outputs one unified log file when running “-O output.log”.
I would love to see an option where you could generate a log file per CTest test into a log directory.
It would be particularly helpful to generate log files for only failing tests.
This would keep the test report clear and concise, but enable debugging.

Behaviour:
Turned on via a command line argument.

--log-per-test

Each test output log would go to a log directory, under testname.log

logs/test_name0.log
logs/test_name1.log
logs/test_name2.log

CTest would create a log file for EACH test, i.e. STD OUT or test output redirects to a log file all the time
OR
Create a log for each failing test only

The output report would report the failing tests like so:

The following tests FAILED:
	  1 - bf16_test0 (Failed)
               Log: (<full_path>/logs/bf16_test0.log)
	  2 - bf16_test1(Failed)
                Log: (<full_path>/logs/bf16_test1.log)

Options
Also here’s some options that would be nice to see

  1. Define log directory:
    Gives the user the option to define a log directory, for when logging is.
    (A better naming convention I think would work better I think)
--log-per-test-dir logs/custom_dir

or using a CTest CMake environment variable:

set(CTEST_PER_TEST_LOG_DIRECTORY, "<something>")
  1. Create a log file only for failing tests
    Gives the user the option to define a log directory, for when logging is.
--log-on-failure-only

or using a CTest CMake environment variable:

set(CTEST_LOG_PER_TEST_ON_FAILURE_ONLY, "<something>")

This feature would help adoption in my organization. Particularly for CI applications

Thanks.

1 Like

I agree with the feature. However, please keep in mind that ctest_test() should also gain access to these so that CTest scripts can utilize the functionality as well.

2 Likes

Yes for sure!

Is this the correct place to define feature requests or must I add them to gitlab issues tracker?

Thanks for asking where to do what, we appreciate the care. :slight_smile:

The forums should be used for asking questions, clarifying things and general discussion about CMake. Feel free to discuss your idea further here if there are aspects you are not sure about yet. Once you have a clear idea of the feature you want to propose, please open a new issue in gitlab with your proposal. It can still be discussed further there, but if it starts out in gitlab with an already clear focus and explanation, that will improve its chances of being actioned by someone with the time and interest.

1 Like

I added a gitlab issue (with simplified and thought out actions).
Could a “triage:feature:” label be applied to it?

https://gitlab.kitware.com/cmake/cmake/-/issues/25090