private void testMIPSFile(String cruxFileName, String inFileName, String outFileName) {
		System.out.printf("Testing crux file \"%s\", with input from \"%s\" and expected output in \"%s\"\n", cruxFileName, inFileName, outFileName);
		useOutBuffer(true);
		SysExitException exitException = null;
		try {
			compiler.compile(cruxFileName);
		} catch (SysExitException see) {
			exitException = see;
		}
		String stdout = outBuffer.toString();
		String errStr = errBuffer.toString();
		useOutBuffer(false);
		assertEquals(stdout, ""); // No errors should occur.
		
		String expected = slurpFile(outFileName);

		// run spim
		String asmFileName = cruxFileName.replace(".crx", ".asm");
		Runtime env = Runtime.getRuntime();
		Process spim = null;
		RandomAccessFile inFile = null;
		byte[] spimInput = null;
		try {
			spim = env.exec("spim -file " + asmFileName);
			inFile = new RandomAccessFile(inFileName, "r");
			spimInput =  new byte[(int) inFile.length()];
			inFile.read(spimInput);
		} catch (IOException ioe) {
			fail(ioe.getMessage());
		}

		OutputStream spimOutStr = spim.getOutputStream();
		InputStream spimInStr = spim.getInputStream();
		InputStream spimErrStr = spim.getErrorStream();

		try {
			spimOutStr.write(spimInput);
			spimOutStr.flush();
			inFile.close();
			spim.waitFor();
		} catch (IOException ioe) {
			fail(ioe.getMessage());
		} catch (InterruptedException ie) {
			fail(ie.getMessage());
		}

		String actual = slurpStream(spimInStr, 5);
		actual += "\n";
		actual = actual.replaceAll("\\r", ""); // So tests can be run under Windoze.

		if (!expected.equals(actual)) {
			StringBuilder errBuilder = new StringBuilder();
			errBuilder.append("Wrong compiler output.\n");
			if (exitException != null) {
				errBuilder.append("(cux-)Compilation caused a System.exit(");
				errBuilder.append(exitException.getExitCode()).append(")\n");
			}
			if (!errStr.isEmpty()) {
				errBuilder.append(String.format("Compiler gave this stderr output: {\n%s\n}\n", errStr));
			}
			try {
				if (spimErrStr.available() != 0) {
					String errString = slurpStream(spimErrStr, 0);
					errBuilder.append("Spim gave this on stderr: " + errString);
				}
			} catch (IOException ioe) {
				fail(ioe.getMessage());
			}

			// Use JUnits smarter diff displayer.
			//errBuilder.append(String.format("exp={\n%s\n}\nact={\n%s\n}\n", expected, actual));
			assertEquals(errBuilder.toString(), expected, actual);
		}
	}