Created
January 13, 2013 02:19
-
-
Save itsjohncs/4521894 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# First grab the test request information from stdin | |
import json | |
import sys | |
test_request = json.load(sys.stdin) | |
import os.path | |
testables_directory = test_request["TESTABLES_DIRECTORY"] | |
main_path = os.path.join(testables_directory, "main.cpp") | |
main_exists = 0 | |
found_hello = 0 | |
found_world = 0 | |
try: | |
with open(main_path) as f: | |
main_exists = 1 | |
for i in f: | |
if "hello" in i.lower(): | |
found_hello = 0.5 | |
elif "world" in i.lower(): | |
found_world = 0.5 | |
except IOError: | |
pass | |
result = { | |
"score": main_exists + found_hello + found_world, | |
"max_score": 2, | |
"tests": [ | |
{ | |
"name": "File Name Correct", | |
"score": main_exists, | |
"max_score": 1, | |
"message": "Found `main.cpp`." if main_exists != 0 else | |
"Could not find `main.cpp`." | |
}, | |
{ | |
"name": "Found Hello World", | |
"score": found_hello + found_world, | |
"max_score": 1, | |
"parts": [ | |
["Found Hello", found_hello, 0.5], | |
["Found World", found_world, 0.5] | |
] | |
} | |
] | |
} | |
json.dump(result, sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment