Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/runners/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,30 @@ module.exports.run = function run(opts, cb) {
}
});

buffer.stderr += stderr;
// let's not show the noisy "Try:" text when there are build errors
buffer.stderr = buffer.stderr.split(/\^* Try:/m)[0];

// attach build output to beginning of stdout, also attach dependencies so everyone knows whats available
// TODO: eventually we want to support this as its own buffer property, for now we are just embedding it
// within the output in case its helpful for troubleshooting
let buildOutput = `Dependencies:\n\n${loadedDependencies()}\n\nTasks:\n\n`;
buildOutput += buildLines.join("\n").replace(/^Start > start.*/gm, '');

// lets strip out any STDERR compiler warnings and and save them for later
const notes = [];
buffer.stderr = buffer.stderr.replace(/^Note:.*\n/gm, function(t) {
notes.push(t);
return '';
});

// now lets move those warnings to the build output
if (notes.length) {
buildOutput += `\n\nCompiler Warnings:\n\n${notes.join("\n")}`;
}

buildOutput = tagHelpers.log('-Build Output', buildOutput);
buffer.stdout = buildOutput + stdout;

buffer.stderr += stderr;
// let's not show the noisy "Try:" text when there are build errors
buffer.stderr = buffer.stderr.split(/\^* Try:/m)[0];
}
});

Expand Down
34 changes: 34 additions & 0 deletions test/runners/java_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,40 @@ describe('java runner', function() {
});
});

describe('compiler warnings as STDERR messages', function() {
it('should handle unchecked or unsafe operations', function(done) {
runner.run({
language: 'java',
code: `
import java.util.ArrayList;

public class Example {

public static String[] dirReduc(String[] arr) {
ArrayList<String> result = new ArrayList();
return result.toArray(new String[result.size()]);
}
}
`,
fixture: `
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class ExampleTest {
@Test
public void testRandomDirReduc() throws Exception {
assertEquals("I always pass!", 1, 1);
}
}`
}, function(buffer) {
console.log(`|${buffer.stderr}|`);
expect(buffer.stderr).to.equal('');
done();
});

});
});

describe('spring', function() {
it('should handle basic junit tests', function(done) {
runner.run({
Expand Down