@@ -1233,8 +1233,9 @@ def status(ignore=False):
1233
1233
dict (name = '--build' , help = "Build directory. Default: .build/" ),
1234
1234
dict (name = '--library' , dest = "compile_library" , action = "store_true" , help = "Compile the current %s as a static library." % cwd_type ),
1235
1235
dict (name = '--tests' , dest = "compile_tests" , action = "store_true" , help = "Compile tests in TESTS directory." ),
1236
+ dict (name = '--test_spec' , dest = "test_spec" , help = "Destination path for a test spec file that can be used by the Greentea automated test tool. (Default is 'test_spec.json')" ),
1236
1237
help = 'Compile program using the native mbed OS build system.' )
1237
- def compile (toolchain = None , mcu = None , source = False , build = False , compile_library = False , compile_tests = False ):
1238
+ def compile (toolchain = None , mcu = None , source = False , build = False , compile_library = False , compile_tests = False , test_spec = "test_spec.json" ):
1238
1239
args = remainder
1239
1240
orig_path = os .getcwd () # remember the original path. this is needed for compiling only the libraries and tests for the current folder.
1240
1241
root_path = Repo .findroot (os .getcwd ())
@@ -1270,37 +1271,24 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
1270
1271
env = os .environ .copy ()
1271
1272
env ['PYTHONPATH' ] = os .path .abspath (root_path )
1272
1273
1273
- def test ( arg , env ) :
1274
- print arg
1274
+ if not source or len ( source ) == 0 :
1275
+ source = [ os . path . relpath ( root_path , orig_path )]
1275
1276
1276
1277
if compile_tests :
1277
1278
# Compile tests
1278
1279
if not build :
1279
- build = os .path .join ('.build' , target , tchain )
1280
-
1281
- tests_path = 'TESTS'
1282
- if os .path .exists (tests_path ):
1283
- # Loop on test group directories
1284
- for d in os .listdir (tests_path ):
1285
- # dir name host_tests is reserved for host python scripts.
1286
- if d != "host_tests" :
1287
- # Loop on test case directories
1288
- for td in os .listdir (os .path .join (tests_path , d )):
1289
- # compile each test
1290
- popen (['python' , os .path .join (tools_dir , 'make.py' )]
1291
- + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
1292
- + ['-t' , tchain , '-m' , target ]
1293
- + ['--source' , os .path .join (tests_path , d , td ), '--source' , '.' ]
1294
- + ['--build' , build ]
1295
- + (['-v' ] if verbose else [])
1296
- + args ,
1297
- env = env )
1298
- if "-c" in args :
1299
- args .remove ('-c' )
1280
+ build = os .path .join (os .path .relpath (root_path , orig_path ), '.build/tests' , target , tchain )
1281
+
1282
+ popen (['python' , os .path .join (tools_dir , 'test.py' )]
1283
+ + ['-t' , tchain , '-m' , target ]
1284
+ + list (chain .from_iterable (izip (repeat ('--source' ), source )))
1285
+ + ['--build' , build ]
1286
+ + ['--test-spec' , test_spec ]
1287
+ + (['-v' ] if verbose else [])
1288
+ + args ,
1289
+ env = env )
1300
1290
elif compile_library :
1301
1291
# Compile as a library (current dir is default)
1302
- if not source or len (source ) == 0 :
1303
- source = [os .path .relpath (root_path , orig_path )]
1304
1292
if not build :
1305
1293
build = os .path .join (os .path .relpath (root_path , orig_path ), '.build' , 'libraries' , os .path .basename (orig_path ), target , tchain )
1306
1294
@@ -1314,8 +1302,6 @@ def test(arg, env):
1314
1302
env = env )
1315
1303
else :
1316
1304
# Compile as application (root is default)
1317
- if not source or len (source ) == 0 :
1318
- source = [os .path .relpath (root_path , orig_path )]
1319
1305
if not build :
1320
1306
build = os .path .join (os .path .relpath (root_path , orig_path ), '.build' , target , tchain )
1321
1307
0 commit comments