Skip to content

Commit a2a265e

Browse files
committed
Merge pull request matyb#27 from nurous/master
Change to logging of compilation failure
2 parents 7d8d79a + edfc26f commit a2a265e

5 files changed

Lines changed: 34 additions & 12 deletions

File tree

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package com.sandwich.util.io;
22

3-
import java.io.File;
4-
import java.util.Arrays;
5-
63
import com.sandwich.koan.ui.SuitePresenter;
74
import com.sandwich.koan.util.ApplicationUtils;
85

6+
import java.io.File;
7+
import java.util.Arrays;
8+
import java.util.Scanner;
9+
910
public class CompilationFailureLogger implements CompilationListener {
10-
public void compilationFailed(File src, String[] command, Process p, Throwable x) {
11+
public void compilationFailed(File src, String[] command, Process p, Throwable x) {
1112
SuitePresenter presenter = ApplicationUtils.getPresenter();
1213
presenter.displayError("\n*****************************************************************");
14+
presenter.displayError("COMPILE FAILED! Exit status was: " + p.exitValue());
15+
presenter.displayError("\nCompile Output:");
16+
presenter.displayError(StreamUtils.convertStreamToString(p.getErrorStream()));
17+
presenter.displayError("Compile Command:");
1318
presenter.displayError(Arrays.toString(command));
14-
presenter.displayError(src.getAbsolutePath() + " does not compile. exit status was: " + p.exitValue());
1519
presenter.displayError("*****************************************************************\n");
20+
System.exit(1);
1621
}
1722
public void compilationSucceeded(File src, String[] command, Process p, Throwable x) { }
1823
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.sandwich.util.io;
2+
3+
import java.io.InputStream;
4+
5+
public class StreamUtils {
6+
7+
public static String convertStreamToString(InputStream stream) {
8+
try {
9+
return new java.util.Scanner(stream).useDelimiter("\\A").next();
10+
} catch (java.util.NoSuchElementException e) {
11+
return "";
12+
}
13+
}
14+
15+
}

‎koans/i18n/messages_en.properties‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ beginner.AboutAssertions.assertBooleanFalse=Like the prior koan. Ponder if you w
66
beginner.AboutAssertions.assertNullObject=A keyword in java to represent an unitialized reference is 'null'. There are times when something should be null, and this assertion can prove that.
77
beginner.AboutAssertions.assertNotNullObject=Sometimes you merely wish to assert an object is not null. This assertion should be used sparingly, often a more specific assertion is appropriate.
88
beginner.AboutAssertions.assertEqualsWithDescriptiveMessage=Like the prior assertions, only this one invokes equals method on the 2nd to last argument, in this case, 1. This will blow up if the last two arguments are not .equal(...)
9-
beginner.AboutAssertions.assertSameInstance=An object may equal another object, but it will never be the same as another object. Two references to the same object is not the same as two references to two equal objects.
10-
beginner.AboutAssertions.assertNotSameInstance=Notice the same instance has been reassigned. Both same and sameReference refer to the same Integer instance. If sameReference were a new Object() of any type [hint!] this would pass.
9+
beginner.AboutAssertions.assertSameInstance=An object may equal another object, but it will never be the same as another object.
10+
beginner.AboutAssertions.assertNotSameInstance=Now we can see that two references to the same object is not the same as two references to two equal objects.
1111

1212
beginner.AboutObjects.objectEqualsNull=An Object instance should NEVER equal null keyword. This applies to all subclasses (everything except primitives subclass Object).
1313
beginner.AboutObjects.objectEqualsSelf=An Object instance should equal itself. This too applies to all subclasses of Object.

‎koans/lib/koans.jar‎

100755100644
4.53 KB
Binary file not shown.

‎koans/src/beginner/AboutAssertions.java‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ public void assertEqualsWithDescriptiveMessage() {
4444

4545
@Koan()
4646
public void assertSameInstance(){
47-
Integer same = new Integer(1);
48-
assertSame(same, __);
47+
Object same = new Integer(1);
48+
Object sameReference = __;
49+
assertSame(same, sameReference);
4950
}
5051

5152
@Koan()
5253
public void assertNotSameInstance(){
53-
Integer same = new Integer(1);
54-
Integer sameReference = same;
55-
assertNotSame(same, sameReference);
54+
Object same = new Integer(1);
55+
Object sameCopy = __;
56+
assertEquals(same, sameCopy);
57+
assertNotSame(same, sameCopy);
5658
}
5759
}

0 commit comments

Comments
 (0)