11package com .sandwich .koan .runner ;
22
3+ import java .io .File ;
34import java .lang .reflect .Constructor ;
45import java .lang .reflect .Method ;
56import java .util .ArrayList ;
910import java .util .Map .Entry ;
1011
1112import com .sandwich .koan .Koan ;
13+ import com .sandwich .koan .KoanClassLoader ;
1214import com .sandwich .koan .KoanMethod ;
1315import com .sandwich .koan .cmdline .behavior .AbstractArgumentBehavior ;
1416import com .sandwich .koan .constant .KoanConstants ;
2325import com .sandwich .util .KoanComparator ;
2426import com .sandwich .util .io .CompilationListener ;
2527import com .sandwich .util .io .DynamicClassLoader ;
26- import com .sandwich .util .io .FileUtils ;
28+ import com .sandwich .util .io .FileCompiler ;
2729import com .sandwich .util .io .KoanSuiteCompilationListener ;
30+ import com .sandwich .util .io .directories .DirectoryManager ;
2831
2932public class RunKoans extends AbstractArgumentBehavior {
3033
@@ -48,7 +51,7 @@ KoanSuiteResult runKoans() {
4851 List <String > failingSuites = new ArrayList <String >();
4952 String level = null ;
5053 KoanMethodResult failure = null ;
51- DynamicClassLoader loader = new DynamicClassLoader ();
54+ DynamicClassLoader loader = KoanClassLoader . getInstance ();
5255 Path pathToEnlightenment = getPathToEnlightenment ();
5356 KoanSuiteCompilationListener compilationListener = new KoanSuiteCompilationListener ();
5457 int successfull = 0 ;
@@ -155,9 +158,11 @@ private Object constructSuite(DynamicClassLoader loader, String className, Compi
155158 throw new RuntimeException (e1 );
156159 } catch (Error e1 ) {
157160 if (e1 .getClass () == Error .class && e1 .getMessage ().contains ("Unresolved compilation problem" )) {
158- listener .compilationFailed (FileUtils .getSourceFileFromClass (className ),
159- new String []{"(compilation yielded a class, but it cannot be cereated)" },
160- -1 , "Unable to load class \" " +className +"\" ." + KoanConstants .EOL +
161+ File sourceFile = FileCompiler .getSourceFileFromClass (
162+ DirectoryManager .getSourceDir (), className );
163+ listener .compilationFailed (
164+ sourceFile , new String []{}, -1 ,
165+ "Unable to load class \" " +className +"\" ." + KoanConstants .EOL +
161166 ExceptionUtils .convertToPopulatedStackTraceString (e1 ), e1 );
162167 return null ; // just consume this exception, this will have been logged and is handled
163168 }else {
0 commit comments