Changes in / [38:77d4f71ee2a7:37:fe97cac0645e] in pyenvjasmine


Ignore:
Files:
8 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • MANIFEST

    r35 r28  
    11# file GENERATED by distutils, do NOT edit
    22README
    3 setup.cfg
    43setup.py
    54pyenvjasmine/__init__.py
  • pyenvjasmine/runner.html

    r36 r12  
    88    <script type="text/javascript" src="file:///%(libDir)s/envjasmine/lib/jasmine/jasmine.js"></script>
    99    <script type="text/javascript" src="file:///%(libDir)s/envjasmine/lib/jasmine/jasmine-html.js"></script>
     10    <script type="text/javascript" src="file:///%(libDir)s/envjasmine/lib/jasmine-ajax/mock-ajax.js"></script>
     11    <script type="text/javascript" src="file:///%(libDir)s/envjasmine/lib/jasmine-ajax/spec-helper.js"></script>
     12    <script type="text/javascript" src="file:///%(libDir)s/envjasmine/lib/jasmine-jquery/jasmine-jquery.js"></script>
    1013
    1114    <script type="text/javascript" src="browser.runner.js"></script>
     
    4043      EnvJasmine.jsDir = "";
    4144      EnvJasmine.testDir = "%(testDir)s";
    42       EnvJasmine.envJasmineLibDir = 'file:///%(libDir)s/envjasmine/lib';
    4345
    4446      EnvJasmine.load = function (path) {
  • pyenvjasmine/runner.py

    r36 r33  
    8989
    9090    watchdog.cancel()  # if it's still waiting to run
     91
    9192    # if it timed out, success is False
    9293    success = (not kill_check.isSet()) and p.returncode >= 0
     
    9495    return (success, ''.join(stdout_l), stderr)
    9596
     97
    9698class Runner(object):
    9799    """
     
    103105
    104106    def __init__(self, rootdir=None, testdir=None, configfile=None,
    105                  browser_configfile=None, testing_enviroment='phantomjs'):
     107                 browser_configfile=None):
    106108        """
    107109        Set up paths, by default everything is
     
    125127        self.configfile = configfile
    126128        self.browser_configfile = browser_configfile
    127         self.runner_js = os.path.join(here, 'run-jasmine3.js')
    128         self.testing_enviroment = testing_enviroment
     129        self.runner_html = os.path.join(here, 'runner.html')
     130
     131    def run(self, spec=None, timeout=None):
     132        """
     133        Run the js tests with envjasmine, return success (true/false) and
     134        the captured stdout data
     135
     136        spec: (relative) path to a spec file (run only that spec)
     137        timeout: Set it to a given number of seconds and the process running
     138                 the js tests will be killed passed that time
     139        """
    129140        environment = get_environment()
    130141        rhino_path = os.path.join(self.rootdir, 'lib', 'rhino', 'js.jar')
     
    132143        rootdir_param = '--rootDir=%s' % self.rootdir
    133144        testdir_param = '--testDir=%s' % self.testdir
    134 
    135         # using a dictionary to parameterize the different engines
    136         self.envs = {
    137             'phantomjs' : {
    138                 'command' : [
    139                     'phantomjs',
    140                     '--debug=true',
    141                     self.runner_js,
    142                     'browser.runner.html'
    143                 ],
    144                 'runner_html' : 'runner3.html',
    145                 'failed_mark' : 'FAILED',
    146                 'success_mark' : '0 failures'
    147             },
    148             'rhino' : {
    149                 'command' : [
    150                     'java',
    151                     '-Duser.timezone=US/Eastern',
    152                     '-Dfile.encoding=utf-8',
    153                     '-jar',
    154                     rhino_path,
    155                     envjasmine_js_path,
    156                     '--disableColor',
    157                     environment,
    158                     rootdir_param,
    159                     testdir_param
    160                 ],
    161                 'runner_html' : 'runner.html',
    162                 'failed_mark' : 'FAILED',
    163                 'success_mark' : 'Failed: 0',
    164                 'command_params_func' : self.command_params_rhino
    165             }
    166         }
    167         self.runner_html = os.path.join(here,
    168                               self.envs[self.testing_enviroment]['runner_html'])
    169 
    170     def command_params_rhino(self, command):
    171         """
    172         Function specific to Rhino to add eventual arguments to the command line.
    173         The function is referenced in the dictionary "envs" with key
    174         "command_params_func", and for every engine that needs the same type of
    175         manipulation there will be a similar function with relative reference in
    176         the dictionary
    177         """
    178         if self.configfile and os.path.exists(self.configfile):
    179            command.append('--configFile=%s' % self.configfile)
    180         return command
    181 
    182     def run(self, spec=None, timeout=None):
    183         """
    184         Run the js tests with envjasmine, return success (true/false) and
    185         the captured stdout data
    186 
    187         spec: (relative) path to a spec file (run only that spec)
    188         timeout: Set it to a given number of seconds and the process running
    189                  the js tests will be killed passed that time
    190         """
    191145        if self.browser_configfile and os.path.exists(self.browser_configfile):
    192146            self.write_browser_htmlfile()
    193         command = self.envs[self.testing_enviroment]['command']
    194         # Add eventual other parameters to the command by calling a
    195         # function specific for the selected engine (rhino, phantomjs, etc.)
    196         if 'command_params_func' in self.envs[self.testing_enviroment]:
    197             command = self.envs[self.testing_enviroment]['command_params_func'](command)
     147
     148        command = [
     149            'java',
     150            '-Duser.timezone=US/Eastern',
     151            '-Dfile.encoding=utf-8',
     152            '-jar',
     153            rhino_path,
     154            envjasmine_js_path,
     155            '--disableColor',
     156            environment,
     157            rootdir_param,
     158            testdir_param
     159            ]
     160
     161        if self.configfile and os.path.exists(self.configfile):
     162            command.append('--configFile=%s' % self.configfile)
     163
    198164        # if we were asked to test only some of the spec files,
    199165        # addd them to the command line:
     
    208174        stderr = subprocess.PIPE
    209175        input_data = ''
     176
    210177        success, stdout, stderr = run_popen_with_timeout(
    211178            command, timeout, input_data, stdin, stdout, stderr
     
    219186
    220187    def did_test_pass(self, stdout):
    221         if self.envs[self.testing_enviroment]['failed_mark'] in stdout:
     188        if 'FAILED' in stdout:
    222189            # it can happen that a test fails because of some timing issues
    223190            # (timer error). In such case it may happen that the test does
     
    231198        # tests passing ok
    232199        for line in stdout.splitlines():
    233             if self.envs[self.testing_enviroment]['success_mark'] in line:
    234                 return True
     200            if 'Failed' in line:
     201                failed = line.split(':')[1].strip()
     202                return failed == '0'
    235203        return False
    236204
  • pyenvjasmine/tests/sample/browser.configfile.js

    r36 r0  
    66EnvJasmine.jsDir = EnvJasmine.testDir + "/code/";
    77EnvJasmine.loadGlobal(EnvJasmine.includeDir + "jquery-1.4.4.js");
    8 EnvJasmine.loadGlobal(EnvJasmine.testDir + '/code/demo.js');
    9 EnvJasmine.loadGlobal(EnvJasmine.testDir + '/mocks/demo.mock.js');
    10 EnvJasmine.loadGlobal(EnvJasmine.testDir + '/tests/specs/test_demo.spec.js');
  • pyenvjasmine/tests/test_runner.py

    r36 r33  
    55
    66
    7 class TestsRunnerRhino(object):
    8 
    9     """
    10     Run the full tests using the old rhino+jasmine1 env
    11     """
     7class TestsRunner(object):
    128
    139    def test_runner_defaults(self):
     
    1511        Test the runner, using default values (which wil run the demo specs)
    1612        """
    17         jstests = Runner(testing_enviroment='rhino')
     13        jstests = Runner()
    1814        success, stdout = jstests.run()
    1915        assert success
     
    3026        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    3127        jstests = Runner(
    32             testing_enviroment='rhino',
    3328            rootdir=envjasmine_dir,
    3429            testdir=sample,
     
    5247        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    5348        jstests = Runner(
    54             testing_enviroment='rhino',
    5549            rootdir=envjasmine_dir,
    5650            testdir=sample,
     
    7468        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    7569        jstests = Runner(
    76             testing_enviroment='rhino',
    7770            rootdir=envjasmine_dir,
    7871            testdir=sample,
     
    10497        # but we want to test also the case when a test failed
    10598        # and it does not appear in the "Failed:" report
    106         jstests = Runner(testing_enviroment='rhino')
     99        jstests = Runner()
    107100        success = jstests.did_test_pass('')
    108101        assert not success
     
    127120        success = jstests.did_test_pass('Failed: something-not-a-number')
    128121        assert not success
    129 
    130 class TestsRunnerPhantomjs(object):
    131 
    132     """
    133     Run the full tests using the phantom+jasmine3 env
    134     """
    135 
    136     def test_write_browser_htmlfile_markup_is_correct(self):
    137         """
    138         Test the created markup
    139         The config file doesn't contain the mock files so jasmine tests
    140         are expected to fail
    141         """
    142         here = os.path.dirname(__file__)
    143         sample = os.path.join(here, 'sample')
    144         browser_conf_file = os.path.join(sample, 'browser.configfile_no_mocks.js')
    145         envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    146         jstests = Runner(
    147             testing_enviroment='phantomjs',
    148             rootdir=envjasmine_dir,
    149             testdir=sample,
    150             browser_configfile=browser_conf_file
    151         )
    152         expected = jstests.create_testRunnerHtml()
    153         jstests.write_browser_htmlfile()
    154         success, stdout = jstests.run()
    155         assert not success
    156         assert '2 test(s) FAILED:' in stdout
    157         with open("browser.runner.html",'r') as file:
    158             actual = file.read()
    159             assert expected == actual
    160 
    161     def test_runner_with_browser_configfile(self):
    162         """
    163         Test the runner, giving it some parameters incl the browser config file
    164         The config file contains the mock files so jasmine tests are expected
    165         to pass
    166         """
    167         here = os.path.dirname(__file__)
    168         sample = os.path.join(here, 'sample')
    169         browser_conf_file = os.path.join(sample, 'browser.configfile.js')
    170         envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    171         jstests = Runner(
    172             testing_enviroment='phantomjs',
    173             rootdir=envjasmine_dir,
    174             testdir=sample,
    175             browser_configfile=browser_conf_file
    176         )
    177         success, stdout = jstests.run()
    178         assert success
    179         assert '0 failures' in stdout
    180 
    181     def test_did_test_pass(self):
    182         # there is some coverage done with the previous tests,
    183         # but we want to test also the case when a test failed
    184         # and it does not appear in the "Failed:" report
    185         here = os.path.dirname(__file__)
    186         sample = os.path.join(here, 'sample')
    187         browser_conf_file = os.path.join(sample, 'browser.configfile.js')
    188 
    189         jstests = Runner(
    190             testing_enviroment='phantomjs',
    191             browser_configfile=browser_conf_file
    192         )
    193         success = jstests.did_test_pass('')
    194         assert not success
    195         success = jstests.did_test_pass('some random data '*50)
    196         assert not success
    197         success = jstests.did_test_pass('some data FAILED some more data')
    198         assert not success
    199         success = jstests.did_test_pass('some data FAILEDsome more data')
    200         assert not success
    201         success = jstests.did_test_pass('0 failures')
    202         assert success
    203         success = jstests.did_test_pass('0 failures FAILED')
    204         assert not success
    205         success = jstests.did_test_pass('0Failed: failures')
    206         assert not success
    207         success = jstests.did_test_pass('1 test(s) FAILED:')
    208         assert not success
    209         success = jstests.did_test_pass('-11 test(s) FAILED:')
    210         assert not success
    211         success = jstests.did_test_pass('something-not-a-number test(s) FAILED:')
    212         assert not success
Note: See TracChangeset for help on using the changeset viewer.