summaryrefslogtreecommitdiff
path: root/yaksh/bash_code_evaluator.py
diff options
context:
space:
mode:
authorankitjavalkar2016-11-16 10:58:25 +0530
committerankitjavalkar2016-11-16 10:58:25 +0530
commit232c4480d47b75fcdb523e5ebb601959c56e40dc (patch)
treec9b519f742015e7f8c635b41710c54c593af7622 /yaksh/bash_code_evaluator.py
parent2100ef108b7119370051f8117c3bb58315fad270 (diff)
downloadonline_test-232c4480d47b75fcdb523e5ebb601959c56e40dc.tar.gz
online_test-232c4480d47b75fcdb523e5ebb601959c56e40dc.tar.bz2
online_test-232c4480d47b75fcdb523e5ebb601959c56e40dc.zip
Fix docstrings, Fix return values of bash evaluator
Diffstat (limited to 'yaksh/bash_code_evaluator.py')
-rw-r--r--yaksh/bash_code_evaluator.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py
index 978586f..dd4445c 100644
--- a/yaksh/bash_code_evaluator.py
+++ b/yaksh/bash_code_evaluator.py
@@ -49,9 +49,11 @@ class BashCodeEvaluator(CodeEvaluator):
Returns (False, error_msg): If mandatory arguments are not files or if
the required permissions are not given to the file(s).
-
"""
ref_code_path = test_case
+ success = False
+ test_case_weightage = 0.0
+
get_ref_path, get_test_case_path = ref_code_path.strip().split(',')
get_ref_path = get_ref_path.strip()
get_test_case_path = get_test_case_path.strip()
@@ -62,19 +64,16 @@ class BashCodeEvaluator(CodeEvaluator):
self.files = copy_files(file_paths)
if not isfile(clean_ref_code_path):
msg = "No file at %s or Incorrect path" % clean_ref_code_path
- return False, msg
+ return False, msg, 0.0
if not isfile(self.submit_code_path):
msg = "No file at %s or Incorrect path" % self.submit_code_path
- return False, msg
+ return False, msg, 0.0
if not os.access(clean_ref_code_path, os.X_OK):
msg = "Script %s is not executable" % clean_ref_code_path
- return False, msg
+ return False, msg, 0.0
if not os.access(self.submit_code_path, os.X_OK):
msg = "Script %s is not executable" % self.submit_code_path
- return False, msg
-
- success = False
- test_case_weightage = 0.0
+ return False, msg, 0.0
user_answer = user_answer.replace("\r", "")
self.write_to_submit_code_file(self.submit_code_path, user_answer)
@@ -99,14 +98,14 @@ class BashCodeEvaluator(CodeEvaluator):
err = "Error: expected %s, got %s" % (inst_stderr,
stdnt_stderr
)
- return False, err, test_case_weightage
+ return False, err, 0.0
else:
if not isfile(clean_test_case_path):
msg = "No test case at %s" % clean_test_case_path
- return False, msg, test_case_weightage
+ return False, msg, 0.0
if not os.access(clean_ref_code_path, os.R_OK):
msg = "Test script %s, not readable" % clean_test_case_path
- return False, msg, test_case_weightage
+ return False, msg, 0.0
# valid_answer is True, so that we can stop once a test case fails
valid_answer = True
# loop_count has to be greater than or equal to one.
@@ -143,4 +142,4 @@ class BashCodeEvaluator(CodeEvaluator):
" {0}, got {1}").format(inst_stdout+inst_stderr,
stdnt_stdout+stdnt_stderr
)
- return False, err, test_case_weightage
+ return False, err, 0.0