def __runUnitTests(): from tiunittest import UnitTest ndk = options.ndk.decode("utf-8") if options.ndk != None else None bbndk = BlackberryNDK(ndk) bb = Blackberry('TemplateTest', 'com.macadamian.template', bbndk) configDescriptor = { 'id':bb.id, 'appname':bb.name, 'platformversion':bb.ndk.version, 'description':'not specified', 'version':'1.0', 'author':'not specified', 'category':'core.games', # TODO MAC: Find out how validate the category 'icon':'assets/appicon.png', 'splashscreen':'assets/default.png' } # Configuration for the project file configProject = { 'appname':bb.name, 'buildlocation':None # TODO MAC: Find out how specify the build location } with UnitTest('Test template replacing on bar-descriptor.xml file..'): passed =__runTemplatingDescriptorTest(configDescriptor) assert passed with UnitTest('Test template replacing on .project file..'): passed = __runTemplatingProjectTest(configProject) assert passed print '\nFinished Running Unit Tests' UnitTest.printDetails()
def __runUnitTests(): from tiunittest import UnitTest ndk = options.ndk.decode("utf-8") if options.ndk != None else None bbndk = BlackberryNDK(ndk) bb = Blackberry('TemplateTest', 'com.macadamian.template', bbndk) configDescriptor = { 'id': bb.id, 'appname': bb.name, 'platformversion': bb.ndk.version, 'description': 'not specified', 'version': '1.0', 'author': 'not specified', 'category': 'core.games', # TODO MAC: Find out how validate the category 'icon': 'assets/appicon.png', 'splashscreen': 'assets/default.png' } # Configuration for the project file configProject = { 'appname': bb.name, 'buildlocation': None # TODO MAC: Find out how specify the build location } with UnitTest('Test template replacing on bar-descriptor.xml file..'): passed = __runTemplatingDescriptorTest(configDescriptor) assert passed with UnitTest('Test template replacing on .project file..'): passed = __runTemplatingProjectTest(configProject) assert passed print '\nFinished Running Unit Tests' UnitTest.printDetails()
def __runUnitTests(ipAddress = None): # on windows the double dirname need to be done on 2 lines baseDir = os.path.abspath(os.path.dirname(sys.argv[0])) baseDir = os.path.dirname(baseDir) sys.path.append(os.path.join(baseDir, 'common')) from tiunittest import UnitTest import tempfile # if there are spaces in the temp directory, try to use the working directory instead if tempfile.gettempdir().find(' ') != -1: if os.getcwd().find(' '): print 'Please run the unit tests from a directory with no spaces' sys.exit(1) else: tempfile.tempdir = os.getcwd() os.environ['TEMP'] = tempfile.tempdir os.environ['TMP'] = tempfile.tempdir os.environ['TMPDIR'] = tempfile.tempdir import shutil print '\nRunning Unit Tests...\n' with UnitTest('Test source environement..'): ndk._sourceEnvironment() for key in ['QNX_TARGET', 'QNX_HOST', 'QNX_CONFIGURATION', 'MAKEFLAGS', 'PATH']: assert key in os.environ with UnitTest('Test find qde..'): qde = ndk._findQde() assert os.path.exists(qde) with UnitTest('Test import project with workspace..'): workspace = tempfile.mkdtemp() projectSrc = os.path.join(ndk.blackberryNdk, 'target', 'qnx6', 'usr', 'share', 'samples', 'ndk', 'HelloWorldDisplay') projectName = 'HelloWorldDisplayMakefile' project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project, workspace) passed = os.path.exists(os.path.join(workspace, '.metadata')) shutil.rmtree(workspace) assert passed with UnitTest('Test import project no workspace..'): workspace = tempfile.mkdtemp() projectSrc = os.path.join(ndk.blackberryNdk, 'target', 'qnx6', 'usr', 'share', 'samples', 'ndk', 'HelloWorldDisplay') project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project) passed = os.path.exists(os.path.join(workspace, '.metadata')) assert passed with UnitTest('Test build project (x86)..'): cpu = 'x86' ndk.build(project, cpu, projectName) assert os.path.exists(os.path.join(project, 'x86', 'o', projectName)) assert os.path.exists(os.path.join(project, 'x86', 'o-g', projectName)) oldDir = os.getcwd() os.chdir(project) with UnitTest('Test package project..'): cpu = 'x86' variant = 'o-g' barPath = os.path.join(project, cpu, variant, '%s.bar' % projectName) savePath = os.path.join(project, cpu, variant, projectName) assert 0 == ndk.package(barPath, savePath, os.path.basename(project), 'simulator', None, isUnitTest = True) assert os.path.exists(barPath) os.chdir(oldDir) if ipAddress != None: with UnitTest('Test deploy project to simulator..'): assert 0 == ndk.deploy(ipAddress, barPath) with UnitTest('Test build project (arm)..'): cpu = 'arm' ndk.build(project, cpu, projectName) assert os.path.exists(os.path.join(project, 'arm', 'o.le-v7', projectName)) assert os.path.exists(os.path.join(project, 'arm', 'o.le-v7-g', projectName)) shutil.rmtree(workspace) print '\nFinished Running Unit Tests' UnitTest.printDetails()
def __runUnitTests(): # on windows the double dirname need to be done on 2 lines baseDir = os.path.abspath(os.path.dirname(sys.argv[0])) baseDir = os.path.dirname(baseDir) sys.path.append(os.path.join(baseDir, 'common')) from tiunittest import UnitTest from tempfile import mkdtemp import shutil print '\nRunning Unit Tests...\n' with UnitTest('Test source environement..'): ndk._sourceEnvironment() for key in ['QNX_TARGET', 'QNX_HOST', 'QNX_CONFIGURATION', 'MAKEFLAGS', 'PATH']: assert key in os.environ with UnitTest('Test find qde..'): qde = ndk._findQde() assert os.path.exists(qde) with UnitTest('Test import project with workspace..'): workspace = mkdtemp() projectSrc = os.path.join(ndk.blackberryNdk, 'target', 'qnx6', 'usr', 'share', 'samples', 'ndk', 'HelloWorldDisplay') projectName = 'HelloWorldDisplayMakefile' project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project, workspace) passed = os.path.exists(os.path.join(workspace, '.metadata')) shutil.rmtree(workspace) assert passed with UnitTest('Test import project no workspace..'): workspace = mkdtemp() projectSrc = os.path.join(ndk.blackberryNdk, 'target', 'qnx6', 'usr', 'share', 'samples', 'ndk', 'HelloWorldDisplay') project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project) passed = os.path.exists(os.path.join(workspace, '.metadata')) assert passed with UnitTest('Test build project (Simulator)..'): variant = 'Simulator-Debug' ndk.build(project, variant) assert os.path.exists(os.path.join(project, 'x86', 'o-g', projectName)) # TODO Mac: Complete the following unit tests # These tests don't work at the moment, we need to figure out how to generate the bar file fisrt # with UnitTest('Test package project..'): # barPath = os.path.join(project, variant, '%s.bar' % projectName) # savePath = os.path.join(project, variant, projectName) # ndk.package(barPath, savePath, os.path.basename(project)) # # with UnitTest('Test deploy project to simulator (hard-coded ip)..'): # ndk.deploy('192.168.135.129', ) # with UnitTest('Test build project (Device-Debug)..'): variant = 'Device-Debug' ndk.build(project, variant) assert os.path.exists(os.path.join(project, 'arm', 'o.le-v7-g', projectName)) with UnitTest('Test build project (Device-Release)..'): variant = 'Device-Release' ndk.build(project, variant) assert os.path.exists(os.path.join(project, 'arm', 'o.le-v7', projectName)) shutil.rmtree(workspace) print '\nFinished Running Unit Tests' UnitTest.printDetails()
def __runUnitTests(ipAddress=None): # on windows the double dirname need to be done on 2 lines baseDir = os.path.abspath(os.path.dirname(sys.argv[0])) baseDir = os.path.dirname(baseDir) sys.path.append(os.path.join(baseDir, "common")) from tiunittest import UnitTest import tempfile # if there are spaces in the temp directory, try to use the working directory instead if tempfile.gettempdir().find(" ") != -1: if os.getcwd().find(" "): print "Please run the unit tests from a directory with no spaces" sys.exit(1) else: tempfile.tempdir = os.getcwd() os.environ["TEMP"] = tempfile.tempdir os.environ["TMP"] = tempfile.tempdir os.environ["TMPDIR"] = tempfile.tempdir import shutil print "\nRunning Unit Tests...\n" with UnitTest("Test source environement.."): ndk._sourceEnvironment() for key in ["QNX_TARGET", "QNX_HOST", "QNX_CONFIGURATION", "MAKEFLAGS", "PATH"]: assert key in os.environ with UnitTest("Test find qde.."): qde = ndk._findQde() assert os.path.exists(qde) with UnitTest("Test import project with workspace.."): workspace = tempfile.mkdtemp() projectSrc = os.path.join( ndk.blackberryNdk, "target", "qnx6", "usr", "share", "samples", "ndk", "HelloWorldDisplay" ) projectName = "HelloWorldDisplayMakefile" project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project, workspace) passed = os.path.exists(os.path.join(workspace, ".metadata")) shutil.rmtree(workspace) assert passed with UnitTest("Test import project no workspace.."): workspace = tempfile.mkdtemp() projectSrc = os.path.join( ndk.blackberryNdk, "target", "qnx6", "usr", "share", "samples", "ndk", "HelloWorldDisplay" ) project = os.path.join(workspace, projectName) shutil.copytree(projectSrc, project) ndk.importProject(project) passed = os.path.exists(os.path.join(workspace, ".metadata")) assert passed with UnitTest("Test build project (x86).."): cpu = "x86" ndk.build(project, cpu, projectName) assert os.path.exists(os.path.join(project, "x86", "o", projectName)) assert os.path.exists(os.path.join(project, "x86", "o-g", projectName)) oldDir = os.getcwd() os.chdir(project) with UnitTest("Test package project.."): cpu = "x86" variant = "o-g" barPath = os.path.join(project, cpu, variant, "%s.bar" % projectName) savePath = os.path.join(project, cpu, variant, projectName) assert 0 == ndk.package(barPath, savePath, os.path.basename(project), "simulator", None, isUnitTest=True) assert os.path.exists(barPath) os.chdir(oldDir) if ipAddress != None: with UnitTest("Test deploy project to simulator.."): assert 0 == ndk.deploy(ipAddress, barPath) with UnitTest("Test build project (arm).."): cpu = "arm" ndk.build(project, cpu, projectName) assert os.path.exists(os.path.join(project, "arm", "o.le-v7", projectName)) assert os.path.exists(os.path.join(project, "arm", "o.le-v7-g", projectName)) shutil.rmtree(workspace) print "\nFinished Running Unit Tests" UnitTest.printDetails()