From d42991c2cf8c6ebafa81b98e11192fe319c9d53e Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 8 May 2024 06:37:00 -0400 Subject: [PATCH] Enable tests to fail --- .../sql/planner/TestPlanMatchingFramework.java | 17 ++++++++++------- .../presto/tests/TestMetadataManager.java | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/presto-main/src/test/java/com/facebook/presto/sql/planner/TestPlanMatchingFramework.java b/presto-main/src/test/java/com/facebook/presto/sql/planner/TestPlanMatchingFramework.java index dbc1c328e7913..9d6cc62b6b6ba 100644 --- a/presto-main/src/test/java/com/facebook/presto/sql/planner/TestPlanMatchingFramework.java +++ b/presto-main/src/test/java/com/facebook/presto/sql/planner/TestPlanMatchingFramework.java @@ -201,26 +201,29 @@ public void testReferenceNonexistentAlias() } /* - * There are so many ways for matches to fail that this is not likely to be generally useful. + * here are so many ways for matches to fail that this is not likely to be generally useful. * Pending better diagnostics, please leave this here, and restrict its use to simple queries * that have few ways to not match a pattern, and functionality that is well-tested with * positive tests. */ - private void assertFails(Runnable runnable) + private void assertPlanFails(Runnable runnable) { + boolean failed = false; try { runnable.run(); - fail("Plans should not have matched!"); } catch (AssertionError e) { - //ignored + failed = true; + } + if (!failed) { + fail("Query was expected to fail but passed"); } } @Test public void testStrictOutputExtraSymbols() { - assertFails(() -> assertMinimallyOptimizedPlan("SELECT orderkey, extendedprice FROM lineitem", + assertPlanFails(() -> assertMinimallyOptimizedPlan("SELECT orderkey, extendedprice FROM lineitem", strictOutput(ImmutableList.of("ORDERKEY"), tableScan("lineitem", ImmutableMap.of("ORDERKEY", "orderkey", "EXTENDEDPRICE", "extendedprice"))))); @@ -229,7 +232,7 @@ public void testStrictOutputExtraSymbols() @Test public void testStrictTableScanExtraSymbols() { - assertFails(() -> assertMinimallyOptimizedPlan("SELECT orderkey, extendedprice FROM lineitem", + assertPlanFails(() -> assertMinimallyOptimizedPlan("SELECT orderkey, extendedprice FROM lineitem", output(ImmutableList.of("ORDERKEY", "EXTENDEDPRICE"), strictTableScan("lineitem", ImmutableMap.of("ORDERKEY", "orderkey"))))); } @@ -237,7 +240,7 @@ public void testStrictTableScanExtraSymbols() @Test public void testStrictProjectExtraSymbols() { - assertFails(() -> assertMinimallyOptimizedPlan("SELECT discount, orderkey, 1 + orderkey FROM lineitem", + assertPlanFails(() -> assertMinimallyOptimizedPlan("SELECT discount, orderkey, 1 + orderkey FROM lineitem", output(ImmutableList.of("ORDERKEY", "EXPRESSION"), strictProject(ImmutableMap.of("EXPRESSION", expression("1 + ORDERKEY"), "ORDERKEY", expression("ORDERKEY")), tableScan("lineitem", ImmutableMap.of("ORDERKEY", "orderkey")))))); diff --git a/presto-tests/src/test/java/com/facebook/presto/tests/TestMetadataManager.java b/presto-tests/src/test/java/com/facebook/presto/tests/TestMetadataManager.java index 8d54c5da6793b..98739db46c920 100644 --- a/presto-tests/src/test/java/com/facebook/presto/tests/TestMetadataManager.java +++ b/presto-tests/src/test/java/com/facebook/presto/tests/TestMetadataManager.java @@ -115,7 +115,7 @@ public void testMetadataIsClearedAfterQueryFailed() queryRunner.execute(sql); fail("expected exception"); } - catch (Throwable t) { + catch (RuntimeException t) { // query should fail }