@@ -47,26 +47,23 @@ extension that uses ``nosetests`` for unit-testing:
47
47
48
48
# !/usr/bin/env python
49
49
50
- import os, sys, platform
50
+ import os
51
+ import sys
52
+ import platform
51
53
import pyctest.pyctest as pyctest
52
54
import pyctest.helpers as helpers
53
55
54
- parser = helpers.ArgumentParser(" ProjectName" , source_dir = os.getcwd(), binary_dir = os.getcwd())
55
- parser.add_argument(" -n" , " --build" , type = str , required = True , help = " Build name for identification" )
56
+ parser = helpers.ArgumentParser(" ProjectName" , source_dir = os.getcwd(),binary_dir = os.getcwd(), vcs_type = " git" )
56
57
args = parser.parse_args()
57
58
58
59
pyctest.BUILD_NAME = " {} " .format(args.build)
59
60
pyctest.BUILD_COMMAND = " python setup.py build_ext --inplace"
60
- pyctest.UPDATE_COMMAND = " git"
61
61
62
62
test = pyctest.test()
63
63
test.SetName(" unittest" )
64
- # insert the command to run the tests for project
65
64
test.SetCommand([" nosetests" ])
66
65
67
- pyctest.generate_config()
68
- pyctest.generate_test_file()
69
- pyctest.run(pyctest.ARGUMENTS )
66
+ pyctest.run()
70
67
71
68
Example for autotools project
72
69
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -75,12 +72,15 @@ Example for autotools project
75
72
76
73
# !/usr/bin/env python
77
74
78
- import os, sys, platform
75
+ import os
76
+ import sys
77
+ import platform
79
78
import multiprocessing as mp
80
79
import pyctest.pyctest as pyctest
81
80
import pyctest.helpers as helpers
82
81
83
- parser = helpers.ArgumentParser(" ProjectName" , source_dir = os.getcwd(), binary_dir = os.getcwd())
82
+ parser = helpers.ArgumentParser(" ProjectName" , source_dir = os.getcwd(), binary_dir = os.getcwd(),
83
+ vcs_type = " git" )
84
84
parser.add_argument(" -n" , " --build" , type = str , required = True , help = " Build name for identification" )
85
85
args = parser.parse_args()
86
86
@@ -91,18 +91,13 @@ Example for autotools project
91
91
cmd.Execute()
92
92
93
93
pyctest.BUILD_NAME = " {} " .format(args.build)
94
- pyctest.UPDATE_COMMAND = " git"
95
94
pyctest.CONFIGURE_COMMAND = " ./configure"
96
95
pyctest.BUILD_COMMAND = " make -j{} " .format(mp.cpu_count())
97
96
98
- test = pyctest.test()
99
- test.SetName(" unittest" )
100
- # insert the command to run the tests for project
101
- test.SetCommand([" ./run-testing.sh" ])
97
+ # alternate test declaration format
98
+ pyctest.test(" unittest" , [" ./run-testing.sh" ])
102
99
103
- pyctest.generate_config()
104
- pyctest.generate_test_file()
105
- pyctest.run(pyctest.ARGUMENTS )
100
+ pyctest.run()
106
101
107
102
Example for CMake project
108
103
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -118,24 +113,21 @@ Example for CMake project
118
113
import pyctest.pyctest as pyctest
119
114
import pyctest.helpers as helpers
120
115
121
- binary_dir = os.path.join(os.getcwd(), " build-ProjectName" )
116
+ project = " PyCTestDemo"
117
+ binary_dir = os.path.join(os.getcwd(), " {} -build" .format(project))
122
118
parser = helpers.ArgumentParser(" ProjectName" , os.getcwd(), binary_dir)
123
119
parser.add_argument(" -n" , " --build" , type = str , required = True , help = " Build name for identification" )
124
120
args = parser.parse_args()
125
121
126
122
pyctest.BUILD_NAME = " {} " .format(args.build)
127
123
pyctest.UPDATE_COMMAND = " git"
128
124
pyctest.CONFIGURE_COMMAND = " cmake {} " .format(pyctest.SOURCE_DIRECTORY )
129
- pyctest.BUILD_COMMAND = " cmake --build {} --target all -- -j{} " .format(pyctest.BINARY_DIRECTORY , mp.cpu_count())
125
+ pyctest.BUILD_COMMAND = " cmake --build {} --target all -- -j{} " .format(
126
+ pyctest.BINARY_DIRECTORY , mp.cpu_count())
130
127
131
- test = pyctest.test()
132
- test.SetName(" unittest" )
133
- # insert the command to run the tests for project
134
- test.SetCommand([" ./run-testing.sh" ])
128
+ pyctest.test(" unittest" , [" ./run-testing.sh" ])
135
129
136
- pyctest.generate_config(pyctest.BINARY_DIRECTORY )
137
- pyctest.generate_test_file(pyctest.BINARY_DIRECTORY )
138
- pyctest.run(pyctest.ARGUMENTS , pyctest.BINARY_DIRECTORY )
130
+ pyctest.run()
139
131
140
132
Python Modules
141
133
~~~~~~~~~~~~~~
@@ -155,6 +147,34 @@ Python Modules
155
147
- It is possible to call CMake from this package but it is generally
156
148
not the purpose
157
149
150
+ Direct Access to CMake/CTest/CPack Executables
151
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152
+
153
+ - ``python -m pyctest.cmake <ARGS> `` == ``cmake <ARGS> ``
154
+ - ``python -m pyctest.ctest <ARGS> `` == ``ctest <ARGS> ``
155
+ - ``python -m pyctest.cpack <ARGS> `` == ``cpack <ARGS> ``
156
+
157
+ Following Python code:
158
+
159
+ .. code :: python
160
+
161
+ from pyctest.ctest import CTest
162
+ from pyctest.cmake import CMake
163
+ from pyctest.cpack import CPack
164
+
165
+ CMake({" CMAKE_BUILD_TYPE" :" Release" }, os.getcwd(), " -G" , " Ninja" )
166
+ CTest(" --build-and-test" , os.getcwd(), " -VV" )
167
+ CPack(" -G" , " TGZ" )
168
+
169
+ is equivalent to the following shell commands:
170
+
171
+ .. code :: bash
172
+
173
+ cmake -DCMAKE_BUILD_TYPE=Release ${PWD} -G Ninja
174
+ ctest --build-and-test ${PWD} -VV
175
+ cpack -G TGZ
176
+
177
+
158
178
Benefits
159
179
~~~~~~~~
160
180
@@ -237,10 +257,7 @@ without any configuration, build, etc. steps
237
257
238
258
import os
239
259
import sys
240
- import shutil
241
- import argparse
242
260
import platform
243
- import traceback
244
261
245
262
import pyctest.pyctest as pyctest
246
263
import pyctest.pycmake as pycmake
@@ -263,49 +280,50 @@ without any configuration, build, etc. steps
263
280
pyctest.MODEL = " Continuous"
264
281
pyctest.SITE = platform.node()
265
282
266
- # create a Test object
283
+ # create a test
267
284
test = pyctest.test()
268
285
test.SetName(" list_directory" )
269
286
test.SetCommand([" ls" , directory])
270
287
test.SetProperty(" WORKING_DIRECTORY" , os.getcwd())
271
288
272
289
# create a second test
273
- # previous test is already stored by PyCTest
274
- test = pyctest.test()
275
- test.SetName(" hostname" )
276
- test.SetCommand([" hostname" ])
277
- test.SetProperty(" TIMEOUT" , " 10" )
278
-
279
- # generate the CTestConfig.cmake and CTestCustom.cmake
280
- pyctest.generate_config(directory)
281
-
282
- # generate the CTestTestfile.cmake file
283
- pyctest.generate_test_file(directory)
290
+ pyctest.test(" hostname" , [" hostname" ], {" TIMEOUT" : " 10" })
284
291
285
292
# run CTest -- e.g. ctest -VV ${PWD}/pycm-test
286
- pyctest.run(pyctest. ARGUMENTS , directory )
293
+ pyctest.run()
287
294
288
295
.. code :: bash
289
296
297
+ # ############################################
298
+ # ____ _ _ ___ ____ ____ ____ ____ #
299
+ # ( _ \( \/ )/ __)(_ _)( __)/ ___)(_ _) #
300
+ # ) __/ ) /( (__ )( ) _) \___ \ )( #
301
+ # (__) (__/ \___) (__) (____)(____/ (__) #
302
+ # #
303
+ # ############################################
304
+
305
+ PyCTest args: []
306
+ CTest args: []
307
+ CMake args: []
290
308
CTest arguments (default): ' -V -DSTAGES=Start;Update;Configure;Build;Test;Coverage;MemCheck -S Stages.cmake -j1'
291
- Writing CTest test file: " /Users/jrmadsen/devel/c++/pyctest-master/pycm-test/CTestTestfile.cmake" ...
309
+ Writing CTest test file: " /Users/jrmadsen/devel/c++/pyctest-master/docs/ pycm-test/CTestTestfile.cmake" ...
292
310
Generating test " list_directory" ...
293
311
Generating test " hostname" ...
294
312
-- STAGES = Start; Update; Configure; Build; Test; Coverage; MemCheck
295
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Running CTEST_START stage...
313
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Running CTEST_START stage...
296
314
Run dashboard with model Continuous
297
- Source directory: /Users/jrmadsen/devel/c++/pyctest-master/pycm-test
298
- Build directory: /Users/jrmadsen/devel/c++/pyctest-master/pycm-test
299
- Track: Continuous
300
- Reading ctest configuration file: /Users/jrmadsen/devel/c++/pyctest-master/pycm-test/CTestConfig.cmake
301
- Site: JRM-macOS-DOE.local
302
- Build name: [Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]
303
- Use Continuous tag: 20181129-2118
304
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_UPDATE stage...
305
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_CONFIGURE stage...
306
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_BUILD stage...
307
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Running CTEST_TEST stage...
308
- Test project /Users/jrmadsen/devel/c++/pyctest-master/pycm-test
315
+ Source directory: /Users/jrmadsen/devel/c++/pyctest-master/docs /pycm-test
316
+ Build directory: /Users/jrmadsen/devel/c++/pyctest-master/docs /pycm-test
317
+ Track: Continuous
318
+ Reading ctest configuration file: /Users/jrmadsen/devel/c++/pyctest-master/docs /pycm-test/CTestConfig.cmake
319
+ Site: JRM-macOS-DOE.local.dhcp.lbl.gov
320
+ Build name: [Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]
321
+ Use Continuous tag: 20190116-2239
322
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_UPDATE stage...
323
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_CONFIGURE stage...
324
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_BUILD stage...
325
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Running CTEST_TEST stage...
326
+ Test project /Users/jrmadsen/devel/c++/pyctest-master/docs/ pycm-test
309
327
Start 1: list_directory
310
328
1/2 Test # 1: list_directory ................... Passed 0.00 sec
311
329
Start 2: hostname
@@ -314,8 +332,8 @@ without any configuration, build, etc. steps
314
332
100% tests passed, 0 tests failed out of 2
315
333
316
334
Total Test time (real) = 0.01 sec
317
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_COVERAGE stage...
318
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_MEMCHECK stage...
319
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Skipping CTEST_SUBMIT stage...
320
- -- [[Darwin macOS 10.13.6 x86_64] [Python 3.6.7 ]] Finished Continuous Stages (Start; Update; Configure; Build; Test; Coverage; MemCheck)
335
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_COVERAGE stage...
336
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_MEMCHECK stage...
337
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Skipping CTEST_SUBMIT stage...
338
+ -- [[Darwin macOS 10.14.2 x86_64] [Python 3.7.0 ]] Finished Continuous Stages (Start; Update; Configure; Build; Test; Coverage; MemCheck)
321
339
0 commit comments