Skip to content

Instantly share code, notes, and snippets.

@scivision
Created February 1, 2024 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/c1525770f8ec22bd9ebc7d3ed6cf8a4b to your computer and use it in GitHub Desktop.
Save scivision/c1525770f8ec22bd9ebc7d3ed6cf8a4b to your computer and use it in GitHub Desktop.
CTest by design combines stdout and stderr. It would be nice if they were separate.
cmake_minimum_required(VERSION 3.19)
project(piper LANGUAGES C)
enable_testing()
add_executable(piper main.c)
add_test(NAME piper COMMAND piper)
#include <stdio.h>
int main(void) {
fprintf(stdout, "stdout pipe\n");
fprintf(stderr, "stderr pipe\n");
return 0;
}
cmake -B build && cmake --build build
# stdout and stderr combined
ctest --test-dir build -V 2>/dev/null
# no output
ctest --test-dir build -V 1>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment