Run tests on Linux, macOS, and Windows (#105)

* Try running tests on all three operating systems

* Try adding an MSVC build

* Make tests work on Windows

* Try reconfiguring Travis for this

* Maybe it's because we're in git bash

* Try explicitly doing something else for travis

* Remove a part I think is unnecessary

* Run the test EXEs as they compile
This commit is contained in:
Ben Visness
2019-07-31 17:22:33 -05:00
committed by GitHub
parent f376f2a2a7
commit a9b08b9147
4 changed files with 51 additions and 11 deletions

View File

@@ -1,7 +1,19 @@
language: cpp
os:
- linux
- osx
compiler:
- clang
- gcc
matrix:
include:
# Windows x64 builds (MSVC)
- os: windows
script:
- ./test.bat travis
before_install:
- eval "${MATRIX_EVAL}"
install:
- cd test
script:

View File

@@ -212,9 +212,9 @@ hmt_covercase* _hmt_covercases = 0;
hmt_category _hmt_new_category(const char* name) {
hmt_category cat = {
.name = name,
.num_tests = 0,
.tests = (hmt_test*) malloc(HMT_ARRAY_SIZE * sizeof(hmt_test))
name, // name
0, // num_tests
(hmt_test*) malloc(HMT_ARRAY_SIZE * sizeof(hmt_test)), // tests
};
return cat;
@@ -222,8 +222,8 @@ hmt_category _hmt_new_category(const char* name) {
hmt_test _hmt_new_test(const char* name, hmt_test_func func) {
hmt_test test = {
.name = name,
.func = func
name, // name
func, // func
};
return test;
@@ -231,10 +231,10 @@ hmt_test _hmt_new_test(const char* name, hmt_test_func func) {
hmt_covercase _hmt_new_covercase(const char* name, int expected) {
hmt_covercase covercase = {
.name = name,
.expected_asserts = expected,
.actual_asserts = 0,
.asserted_lines = (int*) malloc(HMT_ARRAY_SIZE * sizeof(int)),
name, // name
expected, // expected_asserts
0, // actual_asserts
(int*) malloc(HMT_ARRAY_SIZE * sizeof(int)), // asserted_lines
};
return covercase;
@@ -331,8 +331,8 @@ int hmt_run_all_tests() {
printf(" %s:", test.name);
hmt_testresult result = {
.count_cases = 0,
.count_failures = 0
0, // count_cases
0, // count_failures
};
test.func(&result);

View File

@@ -3,6 +3,7 @@
#define HANDMADE_TEST_IMPLEMENTATION
#include "HandmadeTest.h"
#undef COVERAGE // Make sure we don't double-define initializers from the header part
#include "../HandmadeMath.h"
#include "categories/ScalarMath.h"

27
test/test.bat Normal file
View File

@@ -0,0 +1,27 @@
@echo off
if "%1%"=="travis" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64
) else (
where /q cl
if ERRORLEVEL 1 (
for /f "delims=" %%a in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -find VC\Auxiliary\Build\vcvarsall.bat') do (%%a x64)
)
)
if not exist "build" mkdir build
pushd build
cl /Fehmm_test_c.exe ..\HandmadeMath.c ..\hmm_test.c
hmm_test_c
cl /Fehmm_test_c_no_sse.exe /DHANDMADE_MATH_NO_SSE ..\HandmadeMath.c ..\hmm_test.c
hmm_test_c_no_sse
cl /Fehmm_test_cpp.exe ..\HandmadeMath.cpp ..\hmm_test.cpp
hmm_test_cpp
cl /Fehmm_test_cpp_no_sse.exe /DHANDMADE_MATH_NO_SSE ..\HandmadeMath.cpp ..\hmm_test.cpp
hmm_test_cpp_no_sse
popd