from shutil import copyfile,copy



import os
d='.'

cwd = os.getcwd() + "/"


# TODO: Directory met bestandend moet relatief zijn aan dit pad
file1 = cwd+ "data/d1.txt"
file2 =  cwd+ "data/d2.txt"
file3 = cwd+ "data/m1.txt"
file4 =  cwd+ "data/v1.txt"


# TODO: evalutator directory moet relatief zijn aan pad van dit bestand
files1 = cwd + "evaluator/Makefile"
files2 = cwd + "evaluator/Matrix_operators_test.cpp"  
files3 = cwd + "evaluator/evaluator.cpp"  
files4 = cwd + "evaluator/evaluator_exception.h"     
files5 = cwd + "evaluator/individual.cpp"
files6 = cwd + "evaluator/individual.h"
files7 = cwd + "evaluator/MatrixT_operators_test.cpp"  
files8 = cwd + "evaluator/README.txt"                 
files9 = cwd + "evaluator/evaluator.h"    
files10 = cwd + "evaluator/evaluator_string_tools.h" 
files11 = cwd + "evaluator/evaluator_transpose.h" 


from subprocess import call

# TODO: alle opgaven moeten een folder hebben in deze directory
# Ofwel: John/assignment.c
folders = list(filter(lambda x: os.path.isdir(os.path.join(d, x)), os.listdir(d)))
for x in folders:
	# SKIP DATA FOLDER
	if x == "data":
		continue
	if x == "evaluator":
		continue	

	# TODO: DIT KAN HETZELFDE: EERST ALLES KOPIE VAN MAKEN
	# Ik ben te lui om die +"" weg te halen 
	copy( dst=cwd+ x+"",src=file1)
	copy( dst=cwd+ x+"",src=file2)
	copy( dst=cwd+ x+"",src=file3)
	copy( dst=cwd+ x+"",src=file4)
	copy( dst=cwd+ x+"",src=files1)
	copy( dst=cwd+ x+"",src=files2)
	copy( dst=cwd+ x+"",src=files3)
	copy( dst=cwd+ x+"",src=files4)
	copy (dst=cwd+ x+"",src=(files5))
	copy (dst=cwd+ x+"",src=(files6))
	copy (dst=cwd+ x+"",src=(files7))
	copy (dst=cwd+ x+"",src=(files8))
	copy (dst=cwd+ x+"",src=(files9))
	copy (dst=cwd+ x+"",src=(files10))
	copy (dst=cwd+ x+"",src=(files11))


	# HIER ROEP IK MAKE AAN OM TE ZIEN OF HET COMPILEERT EN SCHRIJF IK HET NAAR EEN BESTAND
	status = call("make clean",cwd=cwd+ x+"",shell=True)
	status = call("make > compile_result.txt",cwd=cwd+ x+"",shell=True)


	# BENEDEN TESTS VOOR DEFAULT DINGEN VNA DE OPDRACHT - UITVOER GAAT NAAR BESTAND MET NIVEAU NAAM
	# # Test ontwikkelend default
	status = call('echo " \' ./m1.txt * ./m1.txt " | ./individual | ./evaluator > ontwikkeldn.txt',cwd=cwd+ x+"",shell=True,)
	# Test Vaardig default
	status = call('echo " \' ./m1.txt * ./m1.txt " | ./individual | ./evaluator > vaardig.txt' ,cwd=cwd+ x+"",shell=True,)
	# # Test Competent default
	status = call('echo "(./d1.txt + ./d2.txt) * ./d1.txt" | ./individual | ./evaluator > competent.txt',cwd=cwd+ x+"",shell=True,)
	# # Test gevorderde default
	status = call("echo \" \' ./v1.txt * ~./v1.txt \" | ./individual | ./evaluator > gevorderde.txt",cwd=cwd+ x+"",shell=True,)

