Changeset 7b5898f in sasmodels
- Timestamp:
- Oct 26, 2018 12:28:14 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b9c7379
- Parents:
- df87acf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r012cd34 r7b5898f 45 45 from __future__ import print_function 46 46 47 import argparse 47 48 import sys 48 49 import unittest … … 409 410 410 411 411 def main( *models):412 def main(): 412 413 # type: (*str) -> int 413 414 """ … … 423 424 test_args = {} 424 425 425 if models and models[0] == '-v': 426 verbosity = 2 427 models = models[1:] 428 else: 429 verbosity = 1 430 if models and models[0] == 'opencl': 426 parser = argparse.ArgumentParser(description="Test SasModels Models") 427 parser.add_argument("-v", "--verbose", action="store_const", 428 default=1, const=2, help="Use verbose output") 429 parser.add_argument("engine", metavar="[engine]", 430 help="Engines on which to run the test. " 431 "Valid values are opencl, dll, and opencl_and_dll. " 432 "Defaults to opencl_and_dll if no value is given") 433 parser.add_argument("models", nargs="*", 434 help='The names of the models to be tested. ' 435 'If the first model is "all", then all except the ' 436 'remaining models will be tested.') 437 args, models = parser.parse_known_args() 438 439 if args.engine == "opencl": 431 440 if not use_opencl(): 432 441 print("opencl is not available") 433 442 return 1 434 443 loaders = ['opencl'] 435 models = models[1:] 436 elif models and models[0] == 'dll': 437 # TODO: test if compiler is available? 438 loaders = ['dll'] 439 models = models[1:] 440 elif models and models[0] == 'opencl_and_dll': 444 elif args.engine == "dll": 445 loaders = ["dll"] 446 elif args.engine == "opencl_and_dll": 441 447 loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] 442 models = models[1:]443 448 else: 449 # Default to running both engines 444 450 loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] 445 if not models: 446 print("""\ 447 usage: 448 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 449 450 If -v is included on the command line, then use verbose output. 451 452 If neither opencl nor dll is specified, then models will be tested with 453 both OpenCL and dll; the compute target is ignored for pure python models. 454 455 If model1 is 'all', then all except the remaining models will be tested. 456 457 """) 458 459 return 1 460 461 runner = TestRunner(verbosity=verbosity, **test_args) 462 result = runner.run(make_suite(loaders, models)) 451 args.models.insert(0, args.engine) 452 453 runner = TestRunner(verbosity=args.verbose, **test_args) 454 result = runner.run(make_suite(loaders, args.models)) 463 455 return 1 if result.failures or result.errors else 0 464 456 … … 495 487 496 488 if __name__ == "__main__": 497 sys.exit(main( *sys.argv[1:]))489 sys.exit(main())
Note: See TracChangeset
for help on using the changeset viewer.