-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunTests.cpp
More file actions
100 lines (84 loc) · 2.91 KB
/
Copy pathRunTests.cpp
File metadata and controls
100 lines (84 loc) · 2.91 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* runcpp2
Dependencies:
- Name: System2
Platforms: [DefaultPlatform]
Source:
Git:
URL: "https://github.com/Neko-Box-Coder/System2.git"
LibraryType: Header
IncludePaths: ["."]
*/
#include "System2.h"
#include <string>
#include <stdio.h>
bool RunCommand(std::string command)
{
System2CommandInfo commandInfo = {};
#if defined(_WIN32)
for(int i = 0; i < command.size(); ++i)
command[i] = command[i] == '/' ? '\\' : command[i];
#endif
SYSTEM2_RESULT res = System2Run(command.c_str(), &commandInfo);
if(res != SYSTEM2_RESULT_SUCCESS)
{
printf("Command %s failed with result %i\n", command.c_str(), (int)res);
return false;
}
int retVal;
res = System2GetCommandReturnValue(&commandInfo, -1, &retVal);
if(res != SYSTEM2_RESULT_SUCCESS)
{
printf("Command %s failed to get return value with result %i\n", command.c_str(), (int)res);
return false;
}
if(retVal != 0)
{
printf("Non zero return code %i for command %s\n", retVal, command.c_str());
return false;
}
return true;
}
bool ListDir(const std::string& dirLoc = ".")
{
#if defined(_WIN32)
return RunCommand(std::string("dir ") + dirLoc);
#elif defined(__unix__) || defined(__APPLE__)
return RunCommand(std::string("ls -lah ") + dirLoc);
#endif
}
#define CH(x) do { if(!(x)) { printf("Line %d failed.\n", __LINE__); exit(1); } } while(0)
#define SH(x) CH( RunCommand(x) )
#if defined(_WIN32)
#define RUNCPP2_EXE "Debug/runcpp2.exe"
#else
#define RUNCPP2_EXE "runcpp2"
#endif
#define COMMON_RUNCPP2_ARGS "-l -c ../DefaultYAMLs/DefaultUserConfig.yaml --log-level info"
int main(int, char**)
{
#if 0
CH(ListDir());
SH( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Tests/MultiSourcesAndStatic/Test.cpp");
SH( "cd ./Build && ./" RUNCPP2_EXE " build -o ./TestStaticOutput " COMMON_RUNCPP2_ARGS
" ../Tests/MultiSourcesAndStatic/TestStatic.cpp");
CH(ListDir("./Build/TestStaticOutput"));
SH( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Tests/LocalDependency/TestLocalDependency.cpp");
SH( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Tests/SeparateYaml/TestSeparateYaml.cpp");
if(RunCommand( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Tests/MissingSource/TestMissingSource.yaml"))
{
printf("We expect this to failed, somehow passed?...\n");
return 1;
}
SH( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Tests/YamlOnly/YamlOnlyTest.yaml");
#endif
SH( "cd ./Build && ./" RUNCPP2_EXE " run " COMMON_RUNCPP2_ARGS
" ../Examples/InteractiveTutorial.cpp --test ./" RUNCPP2_EXE
" ../DefaultYAMLs/DefaultUserConfig.yaml");
printf("Done\n");
return 0;
}