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 CLI flag for filtering specific test cases and transactions in pact REPL files #137

Open
salamaashoush opened this issue Jun 1, 2024 · 0 comments

Comments

@salamaashoush
Copy link
Contributor

Is your enhancement request related to a problem? Please describe.

In most test runners (builtin or external), there is always a way to filter out tests you want to run. Currently, in Pact, there is no way to run specific test cases such as expect-*, bench, verify, and typecheck forms, or transactions like begin-tx, from a REPL file. Instead, all tests and transactions in the file must be evaluated.

Describe the solution you'd like

We could introduce a command line flag to filter REPL cases/transactions by their labels. For example, with a REPL file like this:

(begin-tx "hello-world")
  (load "test.pact")
  (expect "should greet the world" "Hello, World!" (test.hello-world))
  (expect "some other test case" "Hello, World!" (test.hello-world))
(commit-tx)

(begin-tx "hello-salama")
  (load "test.pact")
  (expect "should greet salama" "Hello, Salama!" (test.greet "Salama!"))
(commit-tx)

I can run

# Option 1 as an optional positional argument
pact my-module.repl "hello-salama" # will run only the "hello-salama" transaction
pact my-module.repl "hello-world -> should greet the world" # will run only the "should greet the world" test case from the "hello-world" transaction

# Option 2 as an optional argument
pact my-module.repl --testName="hello-salama" # will run only the "hello-salama" transaction
pact my-module.repl --testName="hello-world -> should greet the world" # will run only the "should greet the world" test case from the "hello-world" transaction

these are just to demonstrate the idea and ofc you can implement it the way it fits pact /kadena needs as long as it provide the needed functionality

Describe alternatives you've considered

Additional context

I am working on tooling/editor support, and it is really common for those editors to have a UI to run specific tests from a file. I am working on a Zed editor extension, and they have a nice way to run a test by using a tree-sitter query to find where to place the task run button (the play button from the screenshot)

image

@salamaashoush salamaashoush changed the title Add Command Line Flag for Filtering Specific Test Cases and Transactions in Pact REPL Files Add CLI flag for filtering specific test cases and transactions in pact REPL files Jun 1, 2024
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

No branches or pull requests

1 participant