tidb icon indicating copy to clipboard operation
tidb copied to clipboard

expression: replace `mock.Context` with `StaticExprContext` in tests

Open lcwangchao opened this issue 1 year ago • 7 comments

What problem does this PR solve?

Issue Number: close #53006

Problem Summary:

After we introduced some static implements for EvalContext and ExprContext. It's better to replace mock.Context with StaticExprContext for the following reasons:

  • reduce the dependencies of expression
  • make the test easier to maintain without relying on a hug context

What changed and how does it work?

  • mock.NewContext is replaced with mockStmtExprCtx
  • createContext is replaced with mockStmtTruncateAsWarningExprCtx

Check List

Tests

  • [x] Unit test
  • [ ] Integration test
  • [ ] Manual test (add detailed scripts or steps below)
  • [ ] No need to test
    • [ ] I checked and no code files have been changed.

Side effects

  • [ ] Performance regression: Consumes more CPU
  • [ ] Performance regression: Consumes more Memory
  • [ ] Breaking backward compatibility

Documentation

  • [ ] Affects user behaviors
  • [ ] Contains syntax changes
  • [ ] Contains variable changes
  • [ ] Contains experimental features
  • [ ] Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

lcwangchao avatar Apr 30 '24 08:04 lcwangchao

Hi @lcwangchao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

tiprow[bot] avatar Apr 30 '24 08:04 tiprow[bot]

Codecov Report

:x: Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 57.0801%. Comparing base (479f4be) to head (de97549). :warning: Report is 2964 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #53007         +/-   ##
=================================================
- Coverage   72.8176%   57.0801%   -15.7375%     
=================================================
  Files          1524       1649        +125     
  Lines        435793     631414     +195621     
=================================================
+ Hits         317334     360412      +43078     
- Misses        98816     247146     +148330     
- Partials      19643      23856       +4213     
Flag Coverage Δ
integration 49.1900% <14.2857%> (?)
unit 72.3170% <71.4285%> (-0.1364%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling ∅ <ø> (∅)
parser ∅ <ø> (∅)
br 53.0605% <ø> (+6.2148%) :arrow_up:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Apr 30 '24 08:04 codecov[bot]

/retest

lcwangchao avatar Apr 30 '24 10:04 lcwangchao

[LGTM Timeline notifier]

Timeline:

  • 2024-05-17 05:35:39.678529107 +0000 UTC m=+1804293.435664850: :ballot_box_with_check: agreed by YangKeao.

ti-chi-bot[bot] avatar May 17 '24 05:05 ti-chi-bot[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: YangKeao Once this PR has been reviewed and has the lgtm label, please assign windtalker for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

ti-chi-bot[bot] avatar Jun 28 '24 06:06 ti-chi-bot[bot]

/retest

lcwangchao avatar Jun 28 '24 09:06 lcwangchao

@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

tiprow[bot] avatar Jun 28 '24 09:06 tiprow[bot]

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

ti-chi-bot[bot] avatar Jul 05 '24 22:07 ti-chi-bot[bot]

@lcwangchao: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-e2e-test de975494a0fa783ea63ebfcfc61dac1da166a1bc link true /test pull-integration-e2e-test
pull-integration-realcluster-test-next-gen de975494a0fa783ea63ebfcfc61dac1da166a1bc link true /test pull-integration-realcluster-test-next-gen
pull-unit-test-next-gen de975494a0fa783ea63ebfcfc61dac1da166a1bc link true /test pull-unit-test-next-gen

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

ti-chi-bot[bot] avatar Sep 26 '25 15:09 ti-chi-bot[bot]