Commit 77f924d6 77f924d6abd72dc56955874c1490ceaad7122f3e by Nicolas Perriault

added cli tests for modules

1 parent a7de99b4
...@@ -7,7 +7,7 @@ import sys ...@@ -7,7 +7,7 @@ import sys
7 7
8 def test_cmd(cmd): 8 def test_cmd(cmd):
9 try: 9 try:
10 return subprocess.check_output([__file__] + cmd.split(' ')) 10 return subprocess.check_output([__file__] + cmd.split(' ')).strip()
11 except subprocess.CalledProcessError as err: 11 except subprocess.CalledProcessError as err:
12 sys.stderr.write('FAIL: %s\n' % err) 12 sys.stderr.write('FAIL: %s\n' % err)
13 sys.stderr.write(' return code: %d\n' % err.returncode) 13 sys.stderr.write(' return code: %d\n' % err.returncode)
...@@ -55,11 +55,13 @@ if len(SYS_ARGS) and SYS_ARGS[0] == '__selfcommandtest': ...@@ -55,11 +55,13 @@ if len(SYS_ARGS) and SYS_ARGS[0] == '__selfcommandtest':
55 scripts_path = os.path.join(CASPER_PATH, 'tests', 'commands') 55 scripts_path = os.path.join(CASPER_PATH, 'tests', 'commands')
56 assert(test_cmd('--help').find(pkg_version) > -1) 56 assert(test_cmd('--help').find(pkg_version) > -1)
57 assert(test_cmd('--version').strip() == pkg_version) 57 assert(test_cmd('--version').strip() == pkg_version)
58 assert(test_cmd(os.path.join(scripts_path, 'script.js')) == 'it works\n') 58 assert(test_cmd(os.path.join(scripts_path, 'script.js')) == 'it works')
59 test_output = test_cmd('test --no-colors ' + os.path.join(scripts_path, 'mytest.js')) 59 test_output = test_cmd('test --no-colors ' + os.path.join(scripts_path, 'mytest.js'))
60 assert('PASS ok1' in test_output) 60 assert('PASS ok1' in test_output)
61 assert('PASS ok2' in test_output) 61 assert('PASS ok2' in test_output)
62 assert('PASS ok3' in test_output) 62 assert('PASS ok3' in test_output)
63 module_test = test_cmd(os.path.join(CASPER_PATH, 'tests', 'clitests', 'modules', 'test.js'))
64 assert(module_test == 'hello, world')
63 print('Python executable tests passed.') 65 print('Python executable tests passed.')
64 sys.exit(0) 66 sys.exit(0)
65 67
......
1 /*global patchRequire*/
2 var require = patchRequire(require);
3 var utils = require('utils');
4 exports.hello = utils.format('hello, %s', require('./sub/mod').name);
1 exports.name = 'world';
1 var casper = require('casper').create();
2 var mod = require('./mod');
3 console.log(mod.hello);
4 casper.exit();