Skip to content

Commit 78bf229

Browse files
Adding basic tests to build type
1 parent 1018392 commit 78bf229

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed

Examples/test_static.cpp

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
//bin/true;runcpp2 "$0" "$@"; exit;
2+
3+
/* runcpp2
4+
5+
PassScriptPath: true
6+
BuildType: Static
7+
RequiredProfiles:
8+
Windows: ["msvc"]
9+
Unix: ["g++"]
10+
11+
OtherFilesToBeCompiled:
12+
# Target Platform
13+
DefaultPlatform:
14+
# Target Profile
15+
"g++":
16+
- "./OtherSources/AnotherSourceFileGcc.cpp"
17+
"msvc":
18+
- "./OtherSources/AnotherSourceFileMSVC.cpp"
19+
20+
IncludePaths:
21+
DefaultPlatform:
22+
DefaultProfile:
23+
- "./OtherSources"
24+
25+
Defines:
26+
DefaultPlatform:
27+
# Turns into `TEST_DEF=\"Test Define Working\"` in shell
28+
DefaultProfile: ["TEST_DEF=\\\"Test Define Working\\\""]
29+
30+
Setup:
31+
Unix:
32+
DefaultProfile:
33+
- "echo Setting up script... in $PWD"
34+
Windows:
35+
DefaultProfile:
36+
- "echo Setting up script... in %cd%"
37+
38+
PreBuild:
39+
Unix:
40+
DefaultProfile:
41+
- "echo Starting build... in $PWD"
42+
Windows:
43+
DefaultProfile:
44+
- "echo Starting build... in %cd%"
45+
46+
PostBuild:
47+
Unix:
48+
DefaultProfile:
49+
- "echo Build completed... in $PWD"
50+
Windows:
51+
DefaultProfile:
52+
- "echo Build completed... in %cd%"
53+
54+
Cleanup:
55+
Unix:
56+
DefaultProfile:
57+
- "echo Cleaning up script... in $PWD"
58+
Windows:
59+
DefaultProfile:
60+
- "echo Cleaning up script... in %cd%"
61+
62+
Dependencies:
63+
- Name: ssLogger
64+
Platforms: [Windows, Linux, MacOS]
65+
Source:
66+
Git:
67+
URL: "https://github.com/Neko-Box-Coder/ssLogger.git"
68+
LibraryType: Shared
69+
IncludePaths: ["Include"]
70+
LinkProperties:
71+
DefaultPlatform:
72+
DefaultProfile:
73+
SearchLibraryNames: ["ssLogger"]
74+
ExcludeLibraryNames: ["ssLogger_SRC"]
75+
SearchDirectories: ["./build", "./build/Debug", "./build/Release"]
76+
Setup:
77+
DefaultPlatform:
78+
DefaultProfile:
79+
- "mkdir build"
80+
Build:
81+
DefaultPlatform:
82+
DefaultProfile:
83+
- "cd build && cmake .. -DssLOG_BUILD_TYPE=SHARED"
84+
- "cd build && cmake --build . --config Release -j 16"
85+
FilesToCopy:
86+
# Target Platform (Default, Windows, Linux, MacOS, or Unix)
87+
DefaultPlatform:
88+
DefaultProfile:
89+
- "./Include/ssLogger/ssLog.hpp"
90+
91+
- Name: System2.cpp
92+
Source:
93+
ImportPath: "./TestImport.yaml"
94+
95+
# - Name: System2.cpp
96+
# Platforms: [DefaultPlatform]
97+
# Source:
98+
# Git:
99+
# URL: "https://github.com/Neko-Box-Coder/System2.cpp.git"
100+
# LibraryType: Header
101+
# IncludePaths: [".", "./External/System2"]
102+
# Setup:
103+
# DefaultPlatform:
104+
# DefaultProfile:
105+
# - "git submodule update --init --recursive"
106+
*/
107+
108+
109+
//#include "ssLogger/ssLogInit.hpp"
110+
111+
#define ssLOG_DLL 1
112+
#include "ssLogger/ssLog.hpp"
113+
#include "System2.hpp"
114+
115+
#if defined(__GNUC__)
116+
#include "AnotherSourceFileGcc.hpp"
117+
#endif
118+
119+
#if defined(_MSC_VER)
120+
#include "AnotherSourceFileMSVC.hpp"
121+
#endif
122+
123+
#include <iostream>
124+
#include <chrono>
125+
126+
int main(int argc, char* argv[])
127+
{
128+
std::cout << "Hello World" << std::endl;
129+
std::cout << TEST_DEF << std::endl;
130+
131+
System2CommandInfo commandInfo = {};
132+
int returnCode = 0;
133+
134+
#if defined(_WIN32)
135+
System2CppRun("dir", commandInfo);
136+
#else
137+
auto re = System2CppRun("ls -lah", commandInfo);
138+
#endif
139+
System2CppGetCommandReturnValueSync(commandInfo, returnCode);
140+
141+
for(int i = 0; i < argc; ++i)
142+
std::cout << "Arg" << i << ": " << argv[i] << std::endl;
143+
144+
#if ssLOG_USE_SOURCE
145+
ssLOG_LINE("Source dependency is working!!!");
146+
#else
147+
ssLOG_LINE("Header only dependency is working!!!");
148+
#endif
149+
150+
ssLOG_LINE("Multi source file is working: " << TestFunc());
151+
152+
int CheckCounter = 5;
153+
ssLOG_FATAL("Test fatal: " << CheckCounter);
154+
ssLOG_ERROR("Test error: " << CheckCounter);
155+
ssLOG_WARNING("Test warning: " << CheckCounter);
156+
ssLOG_INFO("Test info: " << CheckCounter);
157+
ssLOG_DEBUG("Test debug: " << CheckCounter);
158+
159+
for(int i = 0; i < 100; ++i)
160+
{
161+
ssLOG_LINE("Logging test: " << i);
162+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
163+
}
164+
165+
return 0;
166+
}

Jenkinsfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ pipeline
255255
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
256256
"--log-level info ../Examples/test.cpp"
257257
}
258+
{
259+
cleanWs()
260+
bash "ls -lah"
261+
unstash 'linux_build'
262+
bash "ls -lah"
263+
bash "ls -lah ./Build/Src/Tests"
264+
bash "cd ./Build && ./runcpp2 -l -b" +
265+
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
266+
"--log-level info ../Examples/test_static.cpp"
267+
}
258268
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
259269
}
260270

@@ -286,6 +296,15 @@ pipeline
286296
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
287297
"--log-level info ..\\..\\Examples\\test.cpp"
288298
}
299+
{
300+
cleanWs()
301+
bat 'dir'
302+
unstash 'windows_build'
303+
bat 'dir'
304+
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b" +
305+
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
306+
"--log-level info ..\\..\\Examples\\test_static.cpp"
307+
}
289308
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
290309
}
291310
}

0 commit comments

Comments
 (0)