-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print USC compilation details (#2631)
<!-- Reference any GitHub issues resolved by this PR --> Closes #2403 ## Introduced changes <!-- A brief description of the changes --> - Print information about compiling Sierra as a spinner message - Skip printing the path for unsaved files ## Checklist <!-- Make sure all of these are complete --> - [X] Linked relevant issue - [X] Updated relevant documentation - [X] Added relevant tests - [X] Performed self-review of the code - [X] Added changes to `CHANGELOG.md`
- Loading branch information
1 parent
d38bc8c
commit 867c645
Showing
6 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use anyhow::Result; | ||
use camino::Utf8Path; | ||
use indicatif::{ProgressBar, ProgressStyle}; | ||
use std::env; | ||
use std::time::Duration; | ||
|
||
pub fn spawn_spinner_message(sierra_file_path: &Utf8Path) -> Result<ProgressBar> { | ||
let spinner = ProgressBar::new_spinner(); | ||
spinner.set_style(ProgressStyle::with_template("\n{spinner} {msg}\n")?); | ||
spinner.enable_steady_tick(Duration::from_millis(100)); | ||
|
||
// Skip printing path when compiling unsaved sierra | ||
// which occurs during test execution for some cheatcodes e.g. `replace_bytecode` | ||
let message = if is_temp_file(sierra_file_path)? { | ||
"Compiling Sierra to Casm".to_string() | ||
} else { | ||
format!( | ||
"Compiling Sierra to Casm ({})", | ||
sierra_file_path.canonicalize_utf8()? | ||
) | ||
}; | ||
spinner.set_message(message); | ||
|
||
Ok(spinner) | ||
} | ||
|
||
fn is_temp_file(file_path: &Utf8Path) -> Result<bool> { | ||
let temp_dir = env::temp_dir().canonicalize()?; | ||
Ok(file_path.canonicalize()?.starts_with(temp_dir)) | ||
} |