[CMake] Running test who have two labels?

Eric Noulard eric.noulard at gmail.com
Sat Mar 25 16:05:53 EDT 2017


2017-03-24 21:17 GMT+01:00 David Cole <DLRdave at aol.com>:

> Here's a bash script wrapper you could use with existing ctest. Save
> it out to a file named ctest-two-labels.sh and then call it with bash
> on Mac or Linux:
>
>
> label1=$1
> label2=$2
>
> if [ -z "$label1" ]; then
>     echo "script takes two label arguments as input, missing arg 1"
>     exit 1
> fi
>
> if [ -z "$label2" ]; then
>     echo "script takes two label arguments as input, missing arg 2"
>     exit 2
> fi
>
> tmpfile=./ctest-two-labels-sh-tmp.txt
> testlistFile=./ctest-two-labels-sh-testlist.txt
> testnumsFile=./ctest-two-labels-sh-testnums.txt
>
> ctest -L "^($label1)$" -N > "$tmpfile"
> ctest -L "^($label2)$" -N >> "$tmpfile"
>
> cat "$tmpfile" | grep "  Test #" | sort | uniq -d > "$testlistFile"
>

Strange enough I got the very same idea to dump and "uniqify" the list I
want.


>
> cat "$testlistFile" | awk -F "#" '{ print $2; }' | awk -F ":" '{ print
> $1; }' > "$testnumsFile"
>
> testnums=$(cat "$testnumsFile" | paste -s -d, -)
>
> #echo Tests with both labels $label1 and $label2:
> #cat "$testlistFile"
> #
> #echo Just the test numbers:
> #cat "$testnumsFile"
> #
> #echo The test numbers, assembled into a ctest -I string to run just
> those numbered tests:
> #echo $testnums
>
> echo Running command line:
> echo ""
> echo "  ctest -I \"0,0,0,$testnums\" -N"
> echo ""
> echo Run it without the -N to actually execute the tests...
> echo ""
>
> ctest -I "0,0,0,$testnums" -N
>
> It's a "back of the envelope / proof of concept" script. Polish it up
> and make it nice if the approach seems reasonable to you.
>

The approach is reasonable. I was simply afraid that dump + filtering of
tests and/or labels
wouldn't be efficient with 600++ tests. That said it's working. Thank you
very much for the proof of concept.
I guess that may be dumping whole tests names (with ctest -N ) and labels
(with --print-labels) would make it
simple for me to craft a script to easily select tests subset with a ctest
wrapper.

It would even be simpler if ctest could dump all tests with associated
labels.
I'll think about it.


-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170325/cf90db8f/attachment.html>


More information about the CMake mailing list