Search code examples
cunit-testingappveyor

How do I run a custom C unit test with Appveyor?


I'm currently writing an open source library in C (https://github.com/Srekel/sralloc) and have a simple unit test solution/project running. It uses a simple C unit testing framework and generates a unittest.exe that prints out the results and returns 1 or 0 depending on if it was successful or not.

My problem is that I'm not sure how to configure Appveyor to run this executable after building. The Appveyor executable is produced at C:\projects\sralloc\examples\Build\x64_Debug\unittest.exe

So I tried this:

test_script:
  - '%APPVEYOR_BUILD_FOLDER%\examples\build\%PLATFORM%_%CONFIGURATION%\unittest.exe'

However Appveyor says: The system cannot find the path specified.

I've searched online a fair amount but haven't really found anything.

Here's my full appveyor.xml

version: 1.0.{build}

image: Visual Studio 2017

configuration:
 - Debug
 - Release

build:
  parallel: true
  project: examples/sralloc.sln

test_script:
  - '%APPVEYOR_BUILD_FOLDER%\examples\build\%PLATFORM%_%CONFIGURATION%\unittest.exe'

Solution

  • I forked your repo and added the following into your appeyor.yml:

    platform:
      - x64
    

    and cannot find the path error disappeared. If you do not have this setting in YAML, there are no environment variable called platform on build VM, and first in list platform is being selected by msbuild.

    Side note: now it stuck with Press any key to continue . . . but I believe this is another subject and you can fix it with altering command line syntax.

    Side note 2: Use this approach to upload text results (I assume your tests can create XML results on one of supported formats.