added cli tests for modules
Showing
4 changed files
with
13 additions
and
2 deletions
... | @@ -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 | ... | ... |
tests/clitests/modules/mod.js
0 → 100644
tests/clitests/modules/sub/mod.js
0 → 100644
1 | exports.name = 'world'; |
tests/clitests/modules/test.js
0 → 100644
-
Please register or sign in to post a comment