diff --git a/src/main/scala/uk/org/floop/sparqlTestRunner/Run.scala b/src/main/scala/uk/org/floop/sparqlTestRunner/Run.scala index 2f4f43f..03824d5 100644 --- a/src/main/scala/uk/org/floop/sparqlTestRunner/Run.scala +++ b/src/main/scala/uk/org/floop/sparqlTestRunner/Run.scala @@ -149,48 +149,57 @@ tests += 1 val query = QueryFactory.create(new String(Files.readAllBytes(f.toPath), StandardCharsets.UTF_8)) val exec = queryExecution(query) - if (query.isSelectType) { - var results = exec.execSelect() - val nonEmptyResults = results.hasNext - val timeTaken = (System.currentTimeMillis() - timeTestStart).toFloat / 1000 - testCases = testCases ++ - { - val out = new ByteArrayOutputStream - ResultSetFormatter.outputAsCSV(out, results) - val actualResults = out.toString("utf-8") - val expect = new File(f.getPath.substring(0, f.getPath.lastIndexOf('.')) + ".expected") - if (expect.exists && expect.isFile) { - val expectedResults = new String(Files.readAllBytes(expect.toPath), StandardCharsets.UTF_8) - if (actualResults != expectedResults) { - errors += 1 - System.err.println(s"Testcase $comment\nExpected:\n$expectedResults\nActual:\n$actualResults") - - } - } else { - // assume there should be no results - if (nonEmptyResults) { - errors += 1 - System.err.println(s"Testcase $comment\nExpected empty result set, got:\n$actualResults") - + try { + if (query.isSelectType) { + var results = exec.execSelect() + val nonEmptyResults = results.hasNext + val timeTaken = (System.currentTimeMillis() - timeTestStart).toFloat / 1000 + testCases = testCases ++ + { + val out = new ByteArrayOutputStream + ResultSetFormatter.outputAsCSV(out, results) + val actualResults = out.toString("utf-8") + val expect = new File(f.getPath.substring(0, f.getPath.lastIndexOf('.')) + ".expected") + if (expect.exists && expect.isFile) { + val expectedResults = new String(Files.readAllBytes(expect.toPath), StandardCharsets.UTF_8) + if (actualResults != expectedResults) { + errors += 1 + System.err.println(s"Testcase $comment\nExpected:\n$expectedResults\nActual:\n$actualResults") + + } + } else { + // assume there should be no results + if (nonEmptyResults) { + errors += 1 + System.err.println(s"Testcase $comment\nExpected empty result set, got:\n$actualResults") + + } } } - } - - } else if (query.isAskType) { - val result = exec.execAsk() - val timeTaken = (System.currentTimeMillis() - timeTestStart).toFloat / 1000 - testCases = testCases ++ { - if (result) { - errors += 1 - System.err.println(s"Testcase $comment\nExpected ASK query to return FALSE") - - }} - } else { - skipped += 1 - System.out.println(s"Skipped testcase $comment") - testCases = testCases ++ - - + + } else if (query.isAskType) { + val result = exec.execAsk() + val timeTaken = (System.currentTimeMillis() - timeTestStart).toFloat / 1000 + testCases = testCases ++ { + if (result) { + errors += 1 + System.err.println(s"Testcase $comment\nExpected ASK query to return FALSE") + + }} + } else { + skipped += 1 + System.out.println(s"Skipped testcase $comment") + testCases = testCases ++ + + + } + } catch { + case e: Exception => + testCases = testCases ++ + + + } } }