Hi Folks, tl;dr I am new here and I am wondering i...
# windows
n
Hi Folks, tl;dr I am new here and I am wondering if the current master branch is expected to fail tests. I am currently working on adding a few tables but before doing anything, I thought I'd run unit tests on the master branch. I believe only 1% of the tests are passing. Am I doing something wrong here?
t
It looks like you did not build the tests. How did you run CMake?
It’s subtle but important to add the configure option mentioned in the testing section here https://osquery.readthedocs.io/en/latest/development/building/
s
By the way, one thing that we could do to make it more obvious maybe is to put all
add_test
directives behind the check of the tests being enabled or not. In that case then it won’t attempt to run anything because there’s no test enabled. It’s only a tad more verbose in CMake code to do.
t
That's a good idea. I wonder if we could hack together a warning "You are trying to run tests but you did not build with testing support."
n
Thanks for the quick response. Oh so I basically should use this‘cmake -G "Visual Studio 16 2019" -A x64 .. -DOSQUERY_BUILD_TESTS=ON’ to be able to run the tests. Will give this a try now!
Got a chance to run it. Was able to pass all the tests except 49 - osquery_filesystem_filesystemtests-test & 64 - plugins_config_parsers_tests_filepathstests-test I am also attaching the respective test logs.
s
@theopolis That’s unfortunately an annoying thing of CMake ahah. The
test
target is a pseudo target, meaning that you can pass it as such in the
cmake --target
command or any `ninja`/`make` command, but it’s not seen as such in CMake code. Also on Windows with msbuild that is
run_tests
. One way I’ve seen it done is to create a custom target/custom command that launches
cmake --build . --target test
and then you can have any command before or after that.. the problem with that is that on Windows with msbuild, 90% of the time you cannot interrupt the tests with a Ctrl+C… and that’s rather annoying.