(File sourceFile, File workingDirectory)
| 101 | } |
| 102 | |
| 103 | private void invokeAcme(File sourceFile, File workingDirectory) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IOException { |
| 104 | String oldPath = System.getProperty("user.dir"); |
| 105 | File tempFile = null; |
| 106 | redirectSystemOutput(); |
| 107 | try { |
| 108 | tempFile = File.createTempFile(sourceFile.getName(), "bin", sourceFile.getParentFile()); |
| 109 | tempFile.deleteOnExit(); |
| 110 | System.setProperty("user.dir", workingDirectory.getAbsolutePath()); |
| 111 | AcmeCrossAssembler acme = new AcmeCrossAssembler(); |
| 112 | String[] params = {"--outfile", normalizeWindowsPath(tempFile.getAbsolutePath()), "-f", "cbm", "--maxerrors","16",normalizeWindowsPath(sourceFile.getAbsolutePath())}; |
| 113 | int status = acme.run("Acme", params); |
| 114 | successful = status == 0; |
| 115 | if (successful) { |
| 116 | compiledAsset = ByteBuffer.wrap(Files.readAllBytes(tempFile.toPath())); |
| 117 | } |
| 118 | tempFile.delete(); |
| 119 | } finally { |
| 120 | restoreSystemOutput(); |
| 121 | System.setProperty("user.dir", oldPath); |
| 122 | if (tempFile != null && tempFile.exists()) { |
| 123 | tempFile.delete(); |
| 124 | } |
| 125 | } |
| 126 | rawOutput.add("Error output:"); |
| 127 | extractOutput(baosErr.toString()); |
| 128 | rawOutput.add(""); |
| 129 | rawOutput.add("------------------------------"); |
| 130 | rawOutput.add("Standard output:"); |
| 131 | extractOutput(baosOut.toString()); |
| 132 | } |
| 133 | |
| 134 | public void extractOutput(String output) throws NumberFormatException { |
| 135 | for (String line : output.split("\\n")) { |
no test coverage detected