Пример #1
0
    def test_relative_path(self):
        tempdir = tempfile.mkdtemp()

        # make a dummy profile
        profile = FirefoxProfile(os.path.join(tempdir, 'testprofilepath'),
                                 restore=False)
        self.assertTrue(os.path.exists(os.path.join(tempdir,
                                                    'testprofilepath',
                                                    'user.js')))

        # make a dummy test
        test = """var test = function () { };"""
        f = file(os.path.join(tempdir, 'test_dummy.js'), 'w')
        f.write(test)
        f.close()

        # run mozmill on it
        process = ProcessHandler(['mozmill',
                                  '-t', 'test_dummy.js',
                                  '--profile=testprofilepath'],
                                 cwd=tempdir)
        process.run()
        process.waitForFinish()

        self.assertNotEqual(process.proc.poll(), None)

        # cleanup
        shutil.rmtree(tempdir)
Пример #2
0
    def test_relative_path(self):
        tempdir = tempfile.mkdtemp()

        # make a dummy profile
        profile = FirefoxProfile(os.path.join(tempdir, 'testprofilepath'),
                                 restore=False)
        self.assertTrue(os.path.exists(os.path.join(tempdir,
                                                    'testprofilepath',
                                                    'user.js')))

        # make a dummy test
        test = """var test = function () { };"""
        f = file(os.path.join(tempdir, 'test_dummy.js'), 'w')
        f.write(test)
        f.close()

        # run mozmill on it
        process = ProcessHandler(['mozmill',
                                  '-t', 'test_dummy.js',
                                  '--profile=testprofilepath'],
                                 cwd=tempdir)
        process.run()
        process.waitForFinish()

        self.assertNotEqual(process.proc.poll(), None)

        # cleanup
        shutil.rmtree(tempdir)
Пример #3
0
    def run_tests(self):
        """
        Run the tests using runtests.py
        """
        # Unfortunately, we can't use --close-when-done on single tests, so just run all of 
        # Harness_sanity and parse out the relevant data.Can change this when Bug 508664 
        # is resolved, as it will allow us to close single tests.
        runtests_location = os.path.join(self.test_path, 'mochitest', 'runtests.py')
        profile_location = os.path.join(self.test_path, 'mochitest', 'profile_path')
        try:
            shutil.rmtree(temp_dir_path)
        except:
            pass
        extra_args = '--repeat=%s'

        harness = 'Harness_sanity'
        extra_profile_file = os.path.join(self.util_path, 'plugins')
        def timeout_log():
            print "Timed out"
        proc = ProcessHandler(['python',
                                runtests_location,
                                '--profile-path=%s' % profile_location, 
                                '--test-path=%s' % harness,
                                extra_args % PLAIN_REPEATS,
                                '--certificate-path=%s' % self.cert_path,
                                '--utility-path=%s' % self.util_path,
                                '--appname=%s' % self.app_name,
                                '--log-file=%s' % self.plain_log_file,
                                '--extra-profile-file=%s' % extra_profile_file,
                                '--close-when-done',
                                '--autorun'
                                ])
        proc.onTimeout = timeout_log
        proc.waitForFinish(timeout=3600, logfile=os.path.join(self.log_dir, "profiler_log_%s" % self.builddata['timestamp']))
        for test_path in CHROME_TESTS:
            proc = ProcessHandler(['python',
                                    runtests_location,
                                    '--profile-path=%s' % profile_location,
                                    '--chrome',
                                    '--test-path=%s' % test_path,
                                    extra_args % CHROME_REPEATS,
                                    '--certificate-path=%s' % self.cert_path,
                                    '--utility-path=%s' % self.util_path,
                                    '--appname=%s' % self.app_name,
                                    '--log-file=%s' % self.chrome_log_file,
                                    '--close-when-done',
                                    '--autorun'
                                    ])
        proc.onTimeout = timeout_log
        proc.waitForFinish(timeout=3600, logfile=os.path.join(self.log_dir, "profiler_log_%s" % self.builddata['timestamp']))
        self.log.info("Done running tests")
Пример #4
0
    def test_options(self):
        absdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        testdir = os.path.join(absdir, 'js-tests')

        process = ProcessHandler([
            'mozmill', '-b', os.environ['BROWSER_PATH'], '-t',
            os.path.join(testdir, 'test_module1.js'), '-m',
            os.path.join(testdir, 'example.ini')
        ])
        process.run()
        process.waitForFinish()

        self.assertNotEqual(
            process.proc.poll(), 0,
            'Parser error due to -t and -m are mutually exclusive')
Пример #5
0
    def test_options(self):
        absdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        testdir = os.path.join(absdir, 'js-tests')

        process = ProcessHandler(['mozmill',
                                  '-b', os.environ['BROWSER_PATH'],
                                  '-t', os.path.join(testdir,
                                                     'test_module1.js'),
                                  '-m', os.path.join(testdir, 'example.ini')
                                 ])
        process.run()
        process.waitForFinish()

        self.assertNotEqual(process.proc.poll(), 0,
                            'Parser error due to -t and -m are mutually exclusive')
Пример #6
0
def test_all_js(tests, options):
    print "Running JS Tests"
    # We run each test in its own instance since these are harness tests.
    # That just seems safer, no opportunity for cross-talk since
    # we are sorta using the framework to test itself
    results = JSResults()

    for t in tests:

        # write a temporary manifest
        manifest = TestManifest()
        manifest.tests = [t]
        fd, filename = tempfile.mkstemp(suffix=".ini")
        os.close(fd)
        fp = file(filename, "w")
        manifest.write(fp=fp)
        fp.close()

        # get CLI arguments to mozmill
        args = ["-b", options.binary]
        args.append("--console-level=DEBUG")
        args.append("-m")
        args.append(filename)

        # run the test
        proc = ProcessHandler("mozmill", args=args)
        proc.run()
        status = proc.waitForFinish(timeout=300)
        command = proc.commandline
        results.acquire(t["name"], proc.output, status, command)

        # remove the temporary manifest
        os.remove(filename)

    return results
Пример #7
0
def test_all_js(tests, options):
    print "Running JS Tests"
    # We run each test in its own instance since these are harness tests.
    # That just seems safer, no opportunity for cross-talk since
    # we are sorta using the framework to test itself
    results = JSResults()

    for t in tests:

        # write a temporary manifest
        manifest = TestManifest()
        manifest.tests = [t]
        fd, filename = tempfile.mkstemp(suffix='.ini')
        os.close(fd)
        fp = file(filename, 'w')
        manifest.write(fp=fp)
        fp.close()

        # get CLI arguments to mozmill
        args = []
        if options.binary:
            args.extend(['-b', options.binary])
        args.append('--console-level=DEBUG')        
        args.append('-m')
        args.append(filename)

        # run the test
        proc = ProcessHandler("mozmill", args=args)
        proc.run()
        status = proc.waitForFinish(timeout=300)
        command = proc.commandline
        results.acquire(t['name'], proc.output, status, command)

        # remove the temporary manifest
        os.remove(filename)
        
    return results
def execute_cmd(cmd, cwd):
    print 'executing', cmd
    proc = ProcessHandler(cmd, cwd=cwd)
    proc.processOutput(timeout=180)
    assert(proc.waitForFinish() == 0)