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

add InjectCall/EnableCall to avoid test code pollute main code #83

Merged
merged 3 commits into from
May 27, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented May 27, 2024

What problem does this PR solve?

What is changed and how it works?

  • with previous Inject/Enable, we you only write code inside main code, and you might need to add some special variable for test. now you can add a one line InjectCall with parameters you want to expose to test, and enable it with EnableCall, see examples/ dir for an example
  • InjectCall/EnableCall requires the inject 'enable' code runs within the same process as the injected code

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to be included in the release note

@CLAassistant
Copy link

CLAassistant commented May 27, 2024

CLA assistant check
All committers have signed the CLA.

@D3Hunter D3Hunter requested a review from lance6716 May 27, 2024 02:51
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

go 1.18
Copy link
Member

Choose a reason for hiding this comment

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

parser has used go1.19.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just upgrade it to the minimal version that compiler complains

hawkingrei
hawkingrei previously approved these changes May 27, 2024
Copy link
Member

@hawkingrei hawkingrei left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

rest lgtm

Makefile Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated
@@ -137,6 +139,7 @@ An implementation of [failpoints][failpoint] for Golang. Fail points are used to

- `func Inject(fpname string, fpblock func(val Value)) {}`
- `func InjectContext(fpname string, ctx context.Context, fpblock func(val Value)) {}`
- `func InjectCall(fpname string, fn any) {}`
Copy link
Contributor

Choose a reason for hiding this comment

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

need to align with the signature in code

@D3Hunter D3Hunter merged commit 9b3b6e3 into master May 27, 2024
2 checks passed
@D3Hunter D3Hunter deleted the inject-call branch May 27, 2024 05:38
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.

4 participants