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

Init Template Option #124

Merged
merged 4 commits into from
Feb 23, 2024
Merged

Init Template Option #124

merged 4 commits into from
Feb 23, 2024

Conversation

lukacan
Copy link
Collaborator

@lukacan lukacan commented Feb 15, 2024

As we are no longer using skip_fuzzer option. It would be helpful to provide the option to generate only the desired test template (for example PoC tests do not need dependencies used for fuzzing).

This PR contains trdelnik init template option:
both - generates templates for both types of tests (+ program_client) [default option]
poc - generates template for PoC tests (+ program_client)
fuzz - generates template for fuzz tests (+ program_client)

@lukacan lukacan requested a review from Ikrk February 15, 2024 22:27
@lukacan lukacan force-pushed the init_option branch 2 times, most recently from 678d835 to bb57356 Compare February 20, 2024 21:46
@lukacan
Copy link
Collaborator Author

lukacan commented Feb 20, 2024

UPDATE!

After the internal discussion, I propose the following changes and updates:

  • trdelnik init contains subcommands for "Both", "PoC", "Fuzz" Tests option, to generate only desired Test Folder/Template

    • Both - generates program_client, fuzz_tests folder and also poc_tests folder with all required subfolders
    • PoC - same as Both but does not generate fuzz_tests folder
    • Fuzz - generates only trdelnik-tests/fuzz_tests folder with all required subfolders
      • .program_client is not required for fuzz tests so program_client is not generated
    • Trdelnik.toml is generated with all cases
    • Worskapce manifest is updated accordingly for PoC/Fuzz tests (this was not modified - only informational)
    • .gitignore is accordingly updated for hfuzz_target - only in case of Fuzz Tests (this was not modified - only informational)
  • Additional changes and updates

  • Build command and Init Command were updated to look for the root directory - this was done previously within the TestGenerator, and the root folder path was sent into all of the used TestGenerator functions. Now within Build,Init and Fuzz(in case of Add) the root is obtained right after the command invocation, and then TestGenerator is created with the root which is then used everywhere required.

  • Similar to the previous point, the Init command right after invocation checks for Anchor.toml/Cargo.toml based on the desired option. For example, for Fuzz Tests we only support projects created by Anchor so it will look for Anchor.

  • In terms of TestGenerator and Commander modules. The logic remains the same however some parts were moved from Commander to the TestGenerator. For Example, creating a program_client crate should be located within the TestGenerator as this is the module where all other files are generated.

  • In terms of fuzz tests. As we do not require to generate program_client, the default file content of fuzz_test.rs was modified to obtain PROGRAM_ID right from the program not from the program_client.

    • Cargo.toml template for Fuzz Tests no longer contains dep for program_client

    TODO: some rustdoc comments would be great

@lukacan
Copy link
Collaborator Author

lukacan commented Feb 21, 2024

I apologize for updating under your hands. The updates are only rebase develop for the latest PR and the build command will not run if Trdelnik is not initialized - Trdelnik.toml not present.

Copy link
Contributor

@Ikrk Ikrk left a comment

Choose a reason for hiding this comment

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

It looks good, only please change the details below...

crates/cli/src/command/init.rs Outdated Show resolved Hide resolved
crates/cli/src/lib.rs Outdated Show resolved Hide resolved
crates/cli/src/lib.rs Outdated Show resolved Hide resolved
@lukacan lukacan requested a review from Ikrk February 21, 2024 23:04
@Ikrk Ikrk merged commit f3741ee into develop Feb 23, 2024
7 checks passed
@Ikrk Ikrk deleted the init_option branch February 23, 2024 08:36
lukacan added a commit that referenced this pull request May 20, 2024
* ✨ Init Template

* Init template updates

* 🐛 Build command to execute only if trdelnik is initialized

* 🐛 fixes
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.

2 participants