diff options
author | prathamesh | 2014-03-13 15:54:23 +0530 |
---|---|---|
committer | prathamesh | 2014-03-13 15:54:23 +0530 |
commit | b46364ad0173f59544cb42b97c42136392f805e6 (patch) | |
tree | 4bd024c59955486a8e43cb53b5ddf0492cd1a485 /testapp | |
parent | 2c8176e4a37ca3a3ecc900bc011da894a90ce801 (diff) | |
download | online_test-b46364ad0173f59544cb42b97c42136392f805e6.tar.gz online_test-b46364ad0173f59544cb42b97c42136392f805e6.tar.bz2 online_test-b46364ad0173f59544cb42b97c42136392f805e6.zip |
Code to test scilab in test_server.py
included timeout with scilab command to prevent scilab from running
scilab infinitely.
Diffstat (limited to 'testapp')
-rwxr-xr-x | testapp/code_server.py | 2 | ||||
-rw-r--r-- | testapp/test_server.py | 36 |
2 files changed, 36 insertions, 2 deletions
diff --git a/testapp/code_server.py b/testapp/code_server.py index c0b92b1..7d9ebd2 100755 --- a/testapp/code_server.py +++ b/testapp/code_server.py @@ -713,7 +713,7 @@ class CodeServer(object): success = False try: cmd = 'printf "lines(0)\nexec(\'{0}\',2);\nquit();"'.format(ref_path) - cmd += ' | scilab-cli -nb' + cmd += ' | timeout 8 scilab-cli -nb' ret = self._run_command(cmd, shell=True, stdout=subprocess.PIPE, diff --git a/testapp/test_server.py b/testapp/test_server.py index 2a17739..31be855 100644 --- a/testapp/test_server.py +++ b/testapp/test_server.py @@ -16,7 +16,6 @@ def check_result(result, check='correct answer'): assert result[0], result[1] assert check in result[1].lower(), result[1] - def test_python(): """Test if server runs Python code as expected.""" src = 'while True: pass' @@ -208,6 +207,40 @@ def test_java(): '/tmp', language="java") check_result(result, 'error') +def test_scilab(): + """Test if server runs java code as expected.""" + src = """ + funcprot(0) +function[c]=add(a,b) + c=a+b; +endfunction + """ + result = code_server.run_code(src, 'scilab_files/test_add.sce', + '/tmp', language="scilab") + check_result(result, 'correct answer') + + src = """ + funcprot(0) +function[c]=add(a,b) + c=a+b; +dis( +endfunction + """ + result = code_server.run_code(src, 'scilab_files/test_add.sce', + '/tmp', language="scilab") + check_result(result, 'error') + + src = """ + funcprot(0) +function[c]=add(a,b) + c=a + while(1==1) + end +endfunction + """ + result = code_server.run_code(src, 'scilab_files/test_add.sce', + '/tmp', language="scilab") + check_result(result, 'error') def test_bash(): """Test if server runs Bash code as expected.""" @@ -257,3 +290,4 @@ if __name__ == '__main__': test_c() test_cpp() test_java() + test_scilab() |