()
| 64 | } |
| 65 | |
| 66 | @Test |
| 67 | public void testRun_setsErrorThrowableOnPigStats() { |
| 68 | File outputFile = null; |
| 69 | try { |
| 70 | String filename = this.getClass().getSimpleName() + "_" + "testRun_setsErrorThrowableOnPigStats"; |
| 71 | outputFile = File.createTempFile(filename, ".out"); |
| 72 | outputFile.delete(); |
| 73 | |
| 74 | File scriptFile = File.createTempFile(filename, ".pig"); |
| 75 | BufferedWriter bw = new BufferedWriter(new FileWriter(scriptFile)); |
| 76 | bw.write("a = load 'test/org/apache/pig/test/data/passwd';\n"); |
| 77 | bw.write("b = group a by $0\n"); |
| 78 | bw.write("c = foreach b generate group, COUNT(a) as cnt;\n"); |
| 79 | bw.write("store c into 'out'\n"); |
| 80 | bw.close(); |
| 81 | |
| 82 | Main.run(new String[]{"-x", "local", scriptFile.getAbsolutePath()}, null); |
| 83 | PigStats stats = PigStats.get(); |
| 84 | |
| 85 | Throwable t = stats.getErrorThrowable(); |
| 86 | assertTrue(t instanceof FrontendException); |
| 87 | |
| 88 | FrontendException fe = (FrontendException) t; |
| 89 | SourceLocation sl = fe.getSourceLocation(); |
| 90 | assertEquals(2, sl.line()); |
| 91 | assertEquals(15, sl.offset()); |
| 92 | |
| 93 | Throwable cause = fe.getCause(); |
| 94 | assertTrue(cause instanceof ParserException); |
| 95 | |
| 96 | } catch (Exception e) { |
| 97 | log.error("Encountered exception", e); |
| 98 | fail("Encountered Exception"); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | @Test |
| 103 | public void testRun_setsErrorThrowableForParamSubstitution() { |
nothing calls this directly
no test coverage detected