2

I'm trying to run Google test in a batch script to run the tests in Jenkins and whereas the tests all pass, Jenkins job status is FAILURE.

here is the batch I'm using:

@echo off
setlocal ENABLEDELAYEDEXPANSION

call "C:\Program Files (x86)\Maxim Integrated\eclipse\eclipsec.exe" --launcher.suppressErrors -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import ".\Loader" -data ./ -cleanBuild "Loader/UnitTest" && (
call .\Loader\UnitTest\Loader.exe
echo Loader status = !ERRORLEVEL!
)

echo !ERRORLEVEL!

And here is the AllTest.cpp where the main() reside:

#include "gtest/gtest.h"
extern "C" void __gcov_flush();

int main(int argc, char** argv)
{
  ::testing::InitGoogleTest(&argc, argv);
  int r = RUN_ALL_TESTS();
  __gcov_flush();
  return r;
}

I've printed "r" in some testing and it is correct (0 or 1 if a test fails) Even if I hardcoded a "42" value in return, it does not work. I get this hardcoded value only if I remove RUN_ALL_TESTS().

And event by cheating like this: 

set ERRORLEVEL= 0

Jenkins still spit a FAILURE job :-/

What am I missing?

Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41
  • `set ERRORLEVEL= 0` will not work.This will just create envirnoment variable errorlevel which will be different than the exit code. Try with `exit /b 0` – npocmaka Sep 06 '17 at 11:28

1 Answers1

0

I've worked around the issue using this: Using gtest in jenkins

so I call gawk after the GTest ran, making Jenkins happy, and use Jenkins' JUnit test plugin according to the linked post.

Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41