run_tests.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. """
  3. This script runs OpenCV.framework tests for OSX.
  4. """
  5. from __future__ import print_function
  6. import os, os.path, sys, argparse, traceback, multiprocessing
  7. # import common code
  8. sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
  9. from run_tests import TestRunner
  10. MACOSX_DEPLOYMENT_TARGET='10.12' # default, can be changed via command line options or environment variable
  11. class OSXTestRunner(TestRunner):
  12. def getToolchain(self):
  13. return None
  14. def getCMakeArgs(self):
  15. args = TestRunner.getCMakeArgs(self)
  16. args = args + [
  17. '-DMACOSX_DEPLOYMENT_TARGET=%s' % os.environ['MACOSX_DEPLOYMENT_TARGET']
  18. ]
  19. return args
  20. if __name__ == "__main__":
  21. script_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
  22. parser = argparse.ArgumentParser(description='The script builds OpenCV.framework for OSX.')
  23. parser.add_argument('tests_dir', metavar='TEST_DIR', help='folder where test files are located')
  24. parser.add_argument('--build_dir', default=None, help='folder where test will be built (default is "../test_build" relative to tests_dir)')
  25. parser.add_argument('--framework_dir', default=None, help='folder where OpenCV framework is located')
  26. parser.add_argument('--framework_name', default='opencv2', help='Name of OpenCV framework (default: opencv2, will change to OpenCV in future version)')
  27. parser.add_argument('--macosx_deployment_target', default=os.environ.get('MACOSX_DEPLOYMENT_TARGET', MACOSX_DEPLOYMENT_TARGET), help='specify MACOSX_DEPLOYMENT_TARGET')
  28. parser.add_argument('--platform', default='macOS,arch=x86_64', help='xcodebuild platform parameter (default is macOS)')
  29. args = parser.parse_args()
  30. os.environ['MACOSX_DEPLOYMENT_TARGET'] = args.macosx_deployment_target
  31. arch = "x86_64"
  32. target = "macOS"
  33. r = OSXTestRunner(script_dir, args.tests_dir, args.build_dir if args.build_dir else os.path.join(args.tests_dir, "../test_build"), args.framework_dir, args.framework_name, arch, target, args.platform)
  34. r.run()