Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable tests to fail #22693

Merged
merged 1 commit into from May 23, 2024
Merged

Enable tests to fail #22693

merged 1 commit into from May 23, 2024

Conversation

elharo
Copy link
Contributor

@elharo elharo commented May 8, 2024

Description

This is a bug pattern I haven't seen before. The AssertionError thrown by the fail method was caught by an overly broad catch clause so the test couldn't fail. This wouldn't have happened with test first development.

Motivation and Context

Tests should fail when broken

Impact

none

Test Plan

CI

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== NO RELEASE NOTE ==

@elharo elharo requested a review from amitkdutta May 8, 2024 10:51
@elharo elharo marked this pull request as ready for review May 11, 2024 11:38
@elharo elharo requested review from jaystarshot, feilong-liu and a team as code owners May 11, 2024 11:38
@elharo elharo requested a review from presto-oss May 11, 2024 11:38
@elharo elharo marked this pull request as draft May 11, 2024 11:39
@elharo elharo force-pushed the fail2 branch 2 times, most recently from d42991c to 169c551 Compare May 12, 2024 13:06
@elharo elharo marked this pull request as ready for review May 14, 2024 13:20
@tdcmeehan tdcmeehan self-assigned this May 14, 2024
* There 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to comment on the function name, since this is looking for plan mismatches and not planning failures, but actually I feel this whole function isn't necessary. PlanAssert already has assertPlanDoesNotMatch, which checks the match result directly and prints a nice error message. I think the tests using this should call to that directly instead of calling a function that calls assertPlan() and then inverting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. It would be nicer to reuse more code and remove this completely. That this exists at all is probably just a relic of code written over multiple years by different devs who didn't always know exactly what already existed where. (I certainly don't.) The existing code is a little convoluted so it might take a minute to rejigger the tests to use PlanAssert.

Copy link
Contributor

@tdcmeehan tdcmeehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, otherwise LGTM

output(ImmutableList.of("ORDERKEY", "EXTENDEDPRICE"),
strictTableScan("lineitem", ImmutableMap.of("ORDERKEY", "orderkey")))));
String sql = "SELECT orderkey, extendedprice FROM lineitem";
ImmutableList<String> outputs = ImmutableList.of("ORDERKEY", "EXTENDEDPRICE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ImmutableList<String> outputs = ImmutableList.of("ORDERKEY", "EXTENDEDPRICE");
List<String> outputs = ImmutableList.of("ORDERKEY", "EXTENDEDPRICE");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 229 to 230
ImmutableList<String> outputs = ImmutableList.of("ORDERKEY", "EXPRESSION");
ImmutableMap<String, ExpressionMatcher> assignments = ImmutableMap.of("EXPRESSION", expression("1 + ORDERKEY"), "ORDERKEY", expression("ORDERKEY"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ImmutableList<String> outputs = ImmutableList.of("ORDERKEY", "EXPRESSION");
ImmutableMap<String, ExpressionMatcher> assignments = ImmutableMap.of("EXPRESSION", expression("1 + ORDERKEY"), "ORDERKEY", expression("ORDERKEY"));
List<String> outputs = ImmutableList.of("ORDERKEY", "EXPRESSION");
Map<String, ExpressionMatcher> assignments = ImmutableMap.of("EXPRESSION", expression("1 + ORDERKEY"), "ORDERKEY", expression("ORDERKEY"));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@elharo elharo merged commit f365a2c into master May 23, 2024
56 checks passed
@elharo elharo deleted the fail2 branch May 23, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants