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

docs: Add build script to test templates #6510

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/book/src/testing/testing-with-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -111,6 +114,7 @@ $ tree
├── Cargo.toml
├── Forc.lock
├── Forc.toml
├── build.rs
├── out
│   └── debug
│   ├── my-fuel-project-abi.json
Expand Down
7 changes: 7 additions & 0 deletions templates/sway-predicate-test-rs/template/build.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions templates/sway-script-test-rs/template/build.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions templates/sway-test-rs/template/build.rs
Original file line number Diff line number Diff line change
@@ -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