<commit_before>import os
from subprocess import Popen, PIPE
import time
import urllib

count = 0

def printline():
	x = ''
	for i in range(80):
		x = x + "="
	print x

def singleTest(qn, ansExp):
	global count

	child = Popen("./exe", stdin=PIPE, stdout=PIPE)
	child.stdin.write(qn)
	child.stdin.close()
	#print "Waiting for read"
	#time.sleep(1)
	ansGot =  child.stdout.read()

	printline()
	count = count + 1
	print "Test number: " + str(count)
	# print "Test input : \n" + qn
	print "Expected Answer :\n" + ansExp
	print "Got this Answer :\n" + ansGot
	if (ansExp != ansGot):
		raise Exception('Test failed')
	else:
		print("Passed")


def smallTests():
	content = "I wonder how many housewives who may read this little book have ever dried sweet corn for winter use."
	singleTest(content, "housewives:  10\n");

def largeTest(url, result):
	filename = url.split("/")[-1]
	if ( not os.path.isfile(filename)):
		testfile = urllib.URLopener()
		testfile.retrieve(url, filename)
	f = open(filename, 'r');
	content = f.read()
	singleTest(content, result)

def largeTests():
	urlTheCount = dict()
	urlTheCount["http://www.gutenberg.org/cache/epub/8190/pg8190.txt"] = "Idiopsychological:  17\n"
	urlTheCount["http://www.gutenberg.org/cache/epub/10554/pg10554.txt"] = "misunderstandings:  17\n"
	for url in urlTheCount:
		largeTest(url, urlTheCount[url]) 



def runTests():
	smallTests()
	largeTests()
	printline()


def compileCode(source):
	printline();
	print "Compiling %s" % source
	ret = os.system('gcc %s -I ../../wordTree/ -I ../../words/ -I ../../trees/ \
../../wordTree/wordTreeBuilder.c ../../words/wordReader.c \
../../trees/bst/binarySearchTree.c -o exe' %source )
	if (ret != 0):
		raise Exception("Did not compile")

def cleanup():
	os.system('rm exe')

def test():
	global count
	sources = ["longestWord.c"]
	for source in sources:
		print
		count = 0
		compileCode(source)
		runTests()<commit_msg>Commit<commit_after>import os
from subprocess import Popen, PIPE
import time
import urllib

count = 0

def printline():
	x = ''
	for i in range(80):
		x = x + "="
	print x

def singleTest(qn, ansExp):
	global count

	child = Popen("./exe", stdin=PIPE, stdout=PIPE)
	child.stdin.write(qn)
	child.stdin.close()
	#print "Waiting for read"
	#time.sleep(1)
	ansGot =  child.stdout.read()

	printline()
	count = count + 1
	print "Test number: " + str(count)
	# print "Test input : \n" + qn
	print "Expected Answer :\n" + ansExp
	print "Got this Answer :\n" + ansGot
	if (ansExp != ansGot):
		raise Exception('Test failed')
	else:
		print("Passed")


def smallTests():
	content = "I wonder how many housewives who may read this little book have ever dried sweet corn for winter use."
	singleTest(content, "housewives:  10\n");

def largeTest(url, result):
	filename = url.split("/")[-1]
	if ( not os.path.isfile(filename)):
		testfile = urllib.URLopener()
		testfile.retrieve(url, filename)
	f = open(filename, 'r');
	content = f.read()
	singleTest(content, result)

def largeTests():
	urlTheCount = dict()
	urlTheCount["http://www.gutenberg.org/cache/epub/8190/pg8190.txt"] = "Idiopsychological:  17\n"
	urlTheCount["http://www.gutenberg.org/cache/epub/10554/pg10554.txt"] = "misunderstandings:  17\n"
	urlTheCount["http://www.gutenberg.org/cache/epub/8178/pg8178.txt"] = "unenthusiastically:  18\n"
	for url in urlTheCount:
		print url
		largeTest(url, urlTheCount[url]) 



def runTests():
	smallTests()
	largeTests()
	printline()


def compileCode(source):
	printline();
	print "Compiling %s" % source
	ret = os.system('gcc %s -I ../../wordTree/ -I ../../words/ -I ../../trees/ \
../../wordTree/wordTreeBuilder.c ../../words/wordReader.c \
../../trees/bst/binarySearchTree.c -o exe' %source )
	if (ret != 0):
		raise Exception("Did not compile")

def cleanup():
	os.system('rm exe')

def test():
	global count
	sources = ["longestWord.c"]
	for source in sources:
		print
		count = 0
		compileCode(source)
		runTests()
{'fraction_non_alphanumeric': 0.1643312101910828, 'fraction_numerical': 0.018853503184713377, 'mean_word_length': 3.770352369380316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3836670', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1437, 'n_words': 378}