Esempio n. 1
0
    def test_generateTestScript(self):
        """
        Test for L{generateTestScript}
        """
        fname = self._outputToTempFile(
            dedent('''
                        // import ConsoleJSTestFoo.Bar
                        // import ConsoleJSTestFoo.Baz
                        print("hello from the test module");
                        '''))

        deps = getDependencies(fname,
                               ignore=(),
                               bootstrap=(),
                               packages=self._getPackages())

        script = generateTestScript(fname, dependencies=deps)

        scriptfname = self._outputToTempFile(script)

        def gotResult(s):
            self.assertEqual(s.split('\n'), [
                'hello from ConsoleJSTestFoo',
                'hello from ConsoleJSTestFoo.Bar',
                'hello from ConsoleJSTestFoo.Baz',
                'hello from the test module', ''
            ])

        result = getProcessOutput(self.javascriptInterpreter,
                                  ('-f', scriptfname))
        result.addCallback(gotResult)
        return result
Esempio n. 2
0
    def test_generateTestScript(self):
        """
        Test for L{generateTestScript}
        """
        fname = self._outputToTempFile(
                    dedent(
                        '''
                        // import ConsoleJSTestFoo.Bar
                        // import ConsoleJSTestFoo.Baz
                        print("hello from the test module");
                        '''))

        deps = getDependencies(
                fname,
                ignore=(),
                bootstrap=(),
                packages=self._getPackages())

        script = generateTestScript(
                    fname,
                    dependencies=deps)

        scriptfname = self._outputToTempFile(script)

        def gotResult(s):
            self.assertEqual(s.split('\n'),
                             ['hello from ConsoleJSTestFoo',
                              'hello from ConsoleJSTestFoo.Bar',
                              'hello from ConsoleJSTestFoo.Baz',
                              'hello from the test module',
                              ''])

        result = getProcessOutput(self.javascriptInterpreter, ('-f', scriptfname))
        result.addCallback(gotResult)
        return result
Esempio n. 3
0
    def makeScript(self, testModule):
        js = """
// import Divmod.UnitTest
// import %(module)s

Divmod.UnitTest.runRemote(Divmod.UnitTest.loadFromModule(%(module)s));
""" % {
            'module': testModule
        }
        jsfile = self._writeToTemp(js)
        scriptFile = self._writeToTemp(generateTestScript(jsfile))
        return scriptFile
Esempio n. 4
0
    def makeScript(self, testModule):
        """
        Write JavaScript source for executing the JavaScript unit tests in
        the given JavaScript module to a file and return the name of that
        file.

        @type testModule: C{str}
        @param testModule: The JavaScript module name which contains the
        tests to run.

        @rtype: C{str}
        """
        jsfile = self._writeToTemp(self.createSource(testModule))
        scriptFile = self._writeToTemp(generateTestScript(jsfile))
        return scriptFile
Esempio n. 5
0
    def makeScript(self, testModule):
        """
        Write JavaScript source for executing the JavaScript unit tests in
        the given JavaScript module to a file and return the name of that
        file.

        @type testModule: C{str}
        @param testModule: The JavaScript module name which contains the
        tests to run.

        @rtype: C{str}
        """
        jsfile = self._writeToTemp(self.createSource(testModule))
        scriptFile = self._writeToTemp(generateTestScript(jsfile))
        return scriptFile
Esempio n. 6
0
    def onetest(self, jsfile):
        """
        Test the javascript file C{jsfile}

        @param jsfile: filename
        @type jsfile: C{str}

        @return: deferred that fires when the javascript interpreter process
        terminates
        @rtype: L{twisted.interner.defer.Deferred}
        """
        p = _JavaScriptTestSuiteProtocol()
        d = p.finished = Deferred()

        fname = self.mktemp()
        file(fname, 'w').write(
            generateTestScript(self.path.child(jsfile).path))

        reactor.spawnProcess(
            p,
            self.javascriptInterpreter,
            ("js", fname))

        return d