summaryrefslogtreecommitdiff
path: root/src/unittest.cc
blob: d2d5167bf464388a16ce01cb70a21f8bba421df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "unittest.h"

#include <iostream>

#include "execute.h"
#include "settings.h"
#include "task.h"

int runUnitTests(std::list<std::shared_ptr<Task>>& tasks,
                 const Settings& settings)
{
	bool ok{true};
	std::cout << "Running unit-tests:\n";
	// Run unit-tests
	for(const auto& task : tasks)
	{
		if(task->targetType() == TargetType::UnitTest)
		{
			std::cout << task->name() << ": ";
			auto ret = execute(task->target(), {}, false);
			ok &= ret == 0;
			if(ret == 0)
			{
				std::cout << "OK\n";
			}
			else
			{
				std::cout << "FAILED\n";
			}
		}
	}

	return ok ? 0 : 1;
}