mirror of
https://github.com/FuelLabs/sway.git
synced 2025-08-18 01:20:37 +00:00
docs: Add build script to test templates (#6510)
## Description Closes https://github.com/FuelLabs/sway/issues/3026 Adds a build script to the test templates that runs prior to the tests when `cargo test` is run. This makes it so users who copy this template don't have to run `forc build` prior to `cargo test` ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com> Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
This commit is contained in:
parent
050ee9dbe2
commit
507870a386
4 changed files with 26 additions and 1 deletions
|
@ -74,18 +74,21 @@ Let's have a look at the result:
|
|||
$ tree .
|
||||
├── Cargo.toml
|
||||
├── Forc.toml
|
||||
├── build.rs
|
||||
├── src
|
||||
│ └── main.sw
|
||||
└── tests
|
||||
└── harness.rs
|
||||
```
|
||||
|
||||
We have two new files!
|
||||
We have three new files!
|
||||
|
||||
- The `Cargo.toml` is the manifest for our new test harness and specifies the
|
||||
required dependencies including `fuels` the Fuel Rust SDK.
|
||||
- The `tests/harness.rs` contains some boilerplate test code to get us started,
|
||||
though doesn't call any contract methods just yet.
|
||||
- The `build.rs` is a build script that compiles the Sway project with `forc build`
|
||||
whenever `cargo test` is run.
|
||||
|
||||
### 4. Build the forc project
|
||||
|
||||
|
@ -111,6 +114,7 @@ $ tree
|
|||
├── Cargo.toml
|
||||
├── Forc.lock
|
||||
├── Forc.toml
|
||||
├── build.rs
|
||||
├── out
|
||||
│ └── debug
|
||||
│ ├── my-fuel-project-abi.json
|
||||
|
|
7
templates/sway-predicate-test-rs/template/build.rs
Normal file
7
templates/sway-predicate-test-rs/template/build.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
//! This build script is used to compile the sway project using `forc` prior to running tests.
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
Command::new("forc").args(&["build"]).status().unwrap();
|
||||
}
|
7
templates/sway-script-test-rs/template/build.rs
Normal file
7
templates/sway-script-test-rs/template/build.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
//! This build script is used to compile the sway project using `forc` prior to running tests.
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
Command::new("forc").args(&["build"]).status().unwrap();
|
||||
}
|
7
templates/sway-test-rs/template/build.rs
Normal file
7
templates/sway-test-rs/template/build.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
//! This build script is used to compile the sway project using `forc` prior to running tests.
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
Command::new("forc").args(&["build"]).status().unwrap();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue