closes#3107
For the motivation for this PR, refer to the issue linked above.
This PR extracts all `tracing` related util functions from `forc-util`
and puts them into a dedicated `forc-tracing` crate. There is a minor
code change
[here](https://github.com/FuelLabs/sway/pull/3108/files#diff-fb650e8292a5d6bc84d8a261393ff2cabe324b5162c40ee5cf23af57ff4dcf58R161-R164)
because it is the only place that `forc-explore` uses `forc-util` (so we
can eliminate the dependency entirely), but other than that this PR is
mostly just moving code around and updating deps as required for crates
dependent on the moved `tracing` utils.
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Previously, the language server was falling out of sync with the users
current workspace edits. For example, incorrect syntax highlighting can
be seen in the below image if the user creates a new line above the
function. The syntax then takes on the previous highlighting and all
other attributes like definition locations, warnings/error locations
etc..
<img width="700" alt="Screen Shot 2022-10-12 at 12 39 47 pm"
src="https://user-images.githubusercontent.com/1289413/195230126-9942e54a-5f61-4a3f-9efa-cf1d21653615.png">
This was happening because we load the project from disk and then get
ASTs to work with from the compiler from these files. As the users
workspace does not match the files saved on disk, then incorrect `Span`s
are in the AST. To get around this, we are cloning the users workspace
into a temporary directory on initialization of the server. On each
keystroke or edit, we update the temp files and save to disk so that we
can get an accurate AST back from the compiler for the language server
to work with. The temp directory is synchronized with the users
workspace on each did_save event.
Finally, we spawn a tokio thread and use the `notify` crate to look for
changes to the projects `Forc.toml` file. We then convert any
dependencies that have a relative path to an absolute path.
closes#2847
I've added error handling now as #2968 was merged before this one was
approved.
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
- [x] Create a new `sway-test-rs` repo or similar that can be used as a
`cargo generate` template.
- [x] Update Rust integration testing docs in the Sway book to describe
how to use the `cargo generate` command to easily add Sway integration
testing to an existing Rust project.
## Follow-up
- Create a `forc-test-rs` crate that re-exports and extends `fuels` with
useful `forc` functionality for integration testing (e.g. re-exporting
`forc_pkg::build` to ensure sway code is built and available under
`out/` at the start of testing).
Closes https://github.com/FuelLabs/sway/issues/2375https://github.com/FuelLabs/sway/issues/2362
Related https://github.com/FuelLabs/sway/pull/2798
1. adds a global `--log-level` option.
1. changes "forc completions --shell" short form from "-s" to "-S"
because "-s" is now globally the short form of "--silent"
1. similarly, changes "forc addr2line --search-dir" short from from "-s"
to "-S"
1. adds a global `--silent` option to all forc commands and renames the
old silent mode to "terse mode".
What used to be called silent mode was not really silent; it would still
output 1 line if there were warnings or errors during the build (for
example, during CI runs).
There is still a need for a non-global option for terse mode because the
test harness runs the build commands directly (without the CLI), so
there's no way to pass the global options into the command (for example,
`forc::test::forc_check::check` which takes a `forc::cli::CheckCommand`
argument).
I can't simply set the log level to "ERROR" for the test harness
(effectively like a terse mode) because it would be applied to all tests
running in that thread, and some of the tests depend on the INFO output
to stdout to determine if the test passed. To have separate log levels
for `ir_generation` and `e2e_vm_tests`, we'd have to separate those into
separate build steps.
Closes https://github.com/FuelLabs/sway/issues/2305
Adds the `--verbose` flag to all forc commands and makes it so
`tracing::debug` logs shows when `-v` or `--verbose` is used, and
`tracing::trace` logs show when `-vv` is used.
If both `RUST_LOG` and the verbose flag are set, the verbose flag takes
precedence.
Tested with permutations of:
```
cargo run -p forc -- clean --verbose
cargo run -p forc -- init -vv
```
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
* chore: bump SDK to 19
* chore: bump SDK to 0.18
* test: update syntax to use builder pattern for contract instantiation
* fix: use StorageConfiguration::default() where needed
* style: fmt
* test: update tests to handle Beck32 changes
* test: start to swap use of &client for &provider in scripts
* chore: bump SDK to 0.19 in forc defaults.rs
* fix: add inputs for utxo validation (#2469)
* chore: update forc default.rs to use v0.20 SDK
* chore: bump SDK to v0.20
Co-authored-by: Ahmed Sagdati <37515857+segfault-magnet@users.noreply.github.com>
This adds a new `--print-ast` option which prints the typed program AST.
You can use it via: `cargo run --bin forc -- build --print-ast --path
test > test.ast`
Spans and Idents are a bit verbose by default, which can be improved
by commenting a few lines in their Debug trait implementation.
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>