Files
apple-foundationdb/tests/TestRunner/TestDirectory.py
Vishesh Yadav a84026cca5 [testing] Automatically discover unit-test and register as ctest (#11612)
* [testing] Automatically discover unit-test and register as ctest

This patch adds `collect_unit_tests()` to CMake which searches over
the codebase and finds all the unit-tests written using Flow's TEST_CASE
macro and register as ctest.

The test then can be then run using ctest command or directly via Test
Explorer in VSCode.

* Update CMakeLists.txt

* Check failed tests

* Update TestDirectory.py to create more unique directory

* Put the feature behind flag
2024-09-04 11:31:49 -07:00

37 lines
971 B
Python
Executable File

#!/usr/bin/env python3
import os
from datetime import datetime
from argparse import ArgumentParser
class TestDirectory:
def __init__(self, builddir):
self.builddir = builddir
def get_test_root(self):
root = os.path.join(self.builddir, "test_runs")
if not os.path.exists(root):
os.mkdir(root)
return root
def create_new_test_dir(self):
t = self.get_test_root()
ts = datetime.now().strftime("%Y_%m_%d__%H_%M_%S_%f")
r = os.path.join(t, ts)
os.mkdir(r)
return r
def get_current_test_dir(self):
r = self.get_test_root()
dirs = list(filter(lambda x: os.path.isdir(os.path.join(r, x)), os.listdir(r)))
dirs.sort()
return os.path.join(r, dirs[-1])
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("builddir")
args = parser.parse_args()
td = TestDirectory(args.builddir)
td.create_new_test_dir()