File: Suite.cpp

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (66 lines) | stat: -rw-r--r-- 2,306 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "stdafx.h"
#include "Compiler/Package.h"

BEGIN_TEST_FN(callStormSuite, Package *pkg, Bool recursive) {
	Engine &e = gEngine();

	VERIFY(pkg != null);

	SimpleName *fnName = parseSimpleName(e, S("test.runTests"));
	fnName->last()->params->push(Value(StormInfo<Package>::type(e)));
	fnName->last()->params->push(Value(StormInfo<Bool>::type(e)));
	fnName->last()->params->push(Value(StormInfo<Bool>::type(e)));
	Function *f = as<Function>(e.scope().find(fnName));
	assert(f, L"Function " + ::toS(fnName) + L" for running tests not found!");
	assert(f->result.isClass(), L"Result for " + ::toS(fnName) + L" must be a class-type.");

	Type *resultType = f->result.type;
	bool verbose = false;
	bool recurse = recursive;
	os::FnCall<RootObject *> c = os::fnCall().add(pkg).add(verbose).add(recurse);
	RootObject *resultVal = c.call(f->ref().address(), false);

	// Inspect the object to find relevant members...
	TestResult our;
	for (NameSet::Iter i = resultType->begin(), end = resultType->end(); i != end; ++i) {
		MemberVar *var = as<MemberVar>(i.v());
		if (!var)
			continue;

		if (*var->name == S("total")) {
			our.total = OFFSET_IN(resultVal, var->rawOffset().current(), Nat);
		} else if (*var->name == S("failed")) {
			our.failed = OFFSET_IN(resultVal, var->rawOffset().current(), Nat);
		} else if (*var->name == S("crashed")) {
			our.crashed = OFFSET_IN(resultVal, var->rawOffset().current(), Nat);
		} else if (*var->name == S("aborted")) {
			our.aborted = OFFSET_IN(resultVal, var->rawOffset().current(), Bool);
		}
	}

	__result__ += our;
} END_TEST_FN

BEGIN_TEST(CoreSuites, BSSuites) {
	Engine &e = gEngine();

	CALL_TEST_FN(callStormSuite, e.package(S("tests.bs")), false);

} END_TEST



// Run any test suites found in tests/suites
BEGIN_TEST(Libraries, BSSuites) {
	Engine &e = gEngine();

	CALL_TEST_FN(callStormSuite, e.package(S("tests.suites")), true);
	CALL_TEST_FN(callStormSuite, e.package(S("sql.tests")), true);
	CALL_TEST_FN(callStormSuite, e.package(S("parser.tests")), true);
	CALL_TEST_FN(callStormSuite, e.package(S("json.tests")), true);
	CALL_TEST_FN(callStormSuite, e.package(S("http.tests")), true);

	// TODO: This takes quite a while, do we want to include it by default?
	// CALL_TEST_FN(callStormSuite, e.package(S("progvis.tests")), true);

} END_TEST