sway
sway copied to clipboard
Remove Rust integration testing behaviour from `forc test` in anticipation of unit testing support
This PR is a WIP that aims to address the first 3 steps in #1833.
This is in anticipation of using forc test to support unit testing (rather than Rust integration testing) #1832.
The forc test command remains for now, but outputs a message explaining that the command is now reserved for unit testing and links to the issues above.
TODO
- [ ] Create a new
sway-test-rsrepo or similar that can be used as acargo generatetemplate. - [ ] Create a
forc-test-rscrate that re-exports and extendsfuelswith usefulforcfunctionality for integration testing (e.g. re-exportingforc_pkg::buildto ensure sway code is built and available underout/at the start of testing). - [ ] Update Rust integration testing docs in the Sway book to describe how to use the
cargo generatecommand to easily add Sway integration testing to an existing Rust project.
Create a new sway-test-rs repo or similar that can be used as a cargo generate template.
Should this be a directory in fuels-rs proper?
Create a new sway-test-rs repo or similar that can be used as a cargo generate template.
Should this be a directory in fuels-rs proper?
I think there's a chance that cargo generate can only handle the case where the crate is at the top-level of the repo, but I could be wrong! I'll do some reading and see if we can refer to a nested repo in a nice manner.
:thinking: If it turns out we can, we might want to consider providing the template from the sway repo rather than fuels-rs, particularly in the case that we want to include some functionality that allows a user to run forc build at the beginning of the test (e.g. to ensure contract ABI is available) as introducing forc also introduces an assumption of there being Sway code in the test.
Another motivator is that our existing test template already assumes things about there being a forc project anyway, i.e. the existence of a <project-name>/out/debug/ directory containing ABI JSON.
We could potentially provide another alternative test template from the fuels-rs that does not make any assumptions about there being a forc project. I'd imagine this might be more important in the future when there are alternative languages/compilers targeting the Fuel VM, or other means of generating Fuel VM bytecode/ABIs.
Just an update for reviewers: Putting this on hold until we land wallet integration in forc deployment. Will come back to this PR after addressing https://github.com/FuelLabs/sway/issues/2412 and https://github.com/FuelLabs/sway/issues/2413.
OK! Just transferred the sway-test-rs cargo generate template repository to FuelLabs, you can find it here: https://github.com/fuellabs/sway-test-rs. I've added some usage steps to its README, just need to update the Sway book to have something similar.
This should be just about ready!
Notable updates:
- The template has been moved from the new
sway-test-rsrepo into a newtemplatessubdirectory within this repo. This allows us to make sure the template is always up to date by testing it under our CI. - The
Test with Rustchapter has been re-written with a more thorough walk-through using the newcargo generatetemplate.
@camiinthisthang just cc'd you for review too in case you'd like to take a look at the Sway Book changes!
@camiinthisthang just cc'd you for review too in case you'd like to take a look at the Sway Book changes!
That's so nice, thank you!