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

Unable to run multiple commands with anchor test. #2771

Closed
dhruvja opened this issue Jan 12, 2024 · 2 comments · Fixed by #2799
Closed

Unable to run multiple commands with anchor test. #2771

dhruvja opened this issue Jan 12, 2024 · 2 comments · Fixed by #2799
Labels
bug Something isn't working cli good first issue Good for newcomers

Comments

@dhruvja
Copy link

dhruvja commented Jan 12, 2024

I have tests in typescript as well as in rust, so i wanted to run both cargo test and yarn ts-mocha ... . So i tried to add both the commands in the scripts section under test tag in anchor.toml file like below.

[scripts]
test = "cargo test --lib -- --nocapture --include-ignored ::anchor; yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

I get the following error

Unrecognized option: 'p'

Both the commands when ran seperately work but when they are together seperated by either ; or &&, they dont seem to work.

When i tried to run the above command in terminal it worked, but i want to make it work with anchor test since it starts and closes the local validator automatically during the process.

@acheroncrypto acheroncrypto added bug Something isn't working good first issue Good for newcomers cli labels Jan 12, 2024
@acheroncrypto
Copy link
Collaborator

Scripts currently accept a single program, therefore anything after cargo is passed as an argument to the cargo command.

As a workaround, you can create test.sh that you want to execute and add:

[scripts]
test = "sh test.sh"

in your Anchor.toml to execute the script with anchor test.

@dhruvja
Copy link
Author

dhruvja commented Jan 12, 2024

As a workaround, you can create test.sh

Thank you for your help, i tried executing sh file and it worked 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants