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

Add flag to reverse errors #4142

Merged
merged 40 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c78e374
Added 'reverse_errors' for 'print_on_failure'
gr00vytvniks Feb 19, 2023
7e959f2
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks Feb 19, 2023
2a78076
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks Feb 20, 2023
6a1f24d
WIP add flag for revering errors
gr00vytvniks Feb 20, 2023
4306e84
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks Feb 23, 2023
5ffad82
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Feb 23, 2023
b6c76d1
Resolved merge conflict
gr00vytvniks Feb 25, 2023
7263f5f
Resolved merge conflict
gr00vytvniks Feb 25, 2023
38f38e9
Removed lock file
gr00vytvniks Mar 11, 2023
e773b58
Resolved merge conflict
gr00vytvniks Mar 15, 2023
af7c51d
resolved merge conflict again
gr00vytvniks Mar 15, 2023
43458d0
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Mar 15, 2023
6b9fbd7
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Mar 17, 2023
86127a7
fmt TOML and changed reverse_errors to false
gr00vytvniks Mar 17, 2023
7daba8d
fmt TOML
gr00vytvniks Mar 17, 2023
819b97a
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Mar 20, 2023
040b4a4
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Mar 27, 2023
9ab4a5d
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Mar 29, 2023
d02d466
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Apr 3, 2023
0090da6
Changed all 'reverse_error' to 'reverse_results', added CLI bindings …
gr00vytvniks Apr 3, 2023
7a281e6
Updated test.rs, deploy.rs, and run.rs with new 'reverse_order' flag …
gr00vytvniks Apr 3, 2023
59fba8b
Resolved merge conflict
gr00vytvniks Apr 14, 2023
aeb87f6
Fixed copy paste errors, had to remove 'build' keyword from run.rs an…
gr00vytvniks Apr 14, 2023
57adbc1
Resolved merge conflict
gr00vytvniks May 9, 2023
34bc878
Resolved merge conflict within 'cargo.lock' file
gr00vytvniks May 9, 2023
698a62c
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks May 9, 2023
f86a74a
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks May 9, 2023
9c857c6
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks May 27, 2023
a524218
resolved merge conflict
gr00vytvniks May 27, 2023
056495b
Deleted extra outdated code
gr00vytvniks May 28, 2023
9535efe
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks Jun 7, 2023
f3f5605
Resolved merge conflict
gr00vytvniks Jun 7, 2023
cba6d6a
Deleted extra line in manifest.rs
gr00vytvniks Jun 8, 2023
a99122a
Merge branch 'master' of https://github.com/gr00vytvniks/sway
gr00vytvniks Jun 10, 2023
e452afc
merge conflict WIP
gr00vytvniks Jun 10, 2023
82c7d05
Merge branch 'FuelLabs:master' into master
gr00vytvniks Jun 21, 2023
780e9eb
Merge branch 'master' into gr00vytvniks/reverse-errors
gr00vytvniks Jun 21, 2023
4e31d6b
resolve merge conflict artifacts
gr00vytvniks Jun 21, 2023
f48caab
Merge branch 'master' into gr00vytvniks/reverse-errors
JoshuaBatty Jun 21, 2023
680794f
Merge branch 'master' into gr00vytvniks/reverse-errors
JoshuaBatty Jun 21, 2023
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
7 changes: 7 additions & 0 deletions forc-pkg/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ pub struct BuildProfile {
pub json_abi_with_callpaths: bool,
#[serde(default)]
pub error_on_warnings: bool,
#[serde(default)]
eureka-cpu marked this conversation as resolved.
Show resolved Hide resolved
pub reverse_results: bool,
pub experimental_private_modules: bool,
eureka-cpu marked this conversation as resolved.
Show resolved Hide resolved
}

impl Dependency {
Expand Down Expand Up @@ -666,6 +669,8 @@ impl BuildProfile {
include_tests: false,
json_abi_with_callpaths: false,
error_on_warnings: false,
experimental_private_modules: false,
eureka-cpu marked this conversation as resolved.
Show resolved Hide resolved
reverse_results: false,
}
}

Expand All @@ -682,6 +687,8 @@ impl BuildProfile {
include_tests: false,
json_abi_with_callpaths: false,
error_on_warnings: false,
experimental_private_modules: false,
eureka-cpu marked this conversation as resolved.
Show resolved Hide resolved
reverse_results: false,
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ pub struct PrintOpts {
pub intermediate_asm: bool,
/// Print the generated Sway IR (Intermediate Representation).
pub ir: bool,
/// Output build errors and warnings in reverse order.
pub reverse_order: bool,
}

#[derive(Default, Clone)]
Expand Down Expand Up @@ -1775,8 +1777,9 @@ pub fn compile(
sway_build_config(pkg.manifest_file.dir(), &entry_path, pkg.target, profile)?
);
let terse_mode = profile.terse;
let reverse_results = profile.reverse_results;
let fail = |warnings, errors| {
print_on_failure(terse_mode, warnings, errors);
print_on_failure(terse_mode, warnings, errors, reverse_results);
bail!("Failed to compile {}", pkg.name);
};

Expand Down Expand Up @@ -2258,7 +2261,7 @@ pub fn build(
};

let fail = |warnings, errors| {
print_on_failure(profile.terse, warnings, errors);
print_on_failure(profile.terse, warnings, errors, profile.reverse_results);
bail!("Failed to compile {}", pkg.name);
};

Expand Down Expand Up @@ -2346,7 +2349,10 @@ pub fn build(
contract_id_value.clone(),
) {
Ok(o) => o,
Err(errs) => return fail(&[], &errs),
Err(errs) => {
print_on_failure(profile.terse, &[], &errs, profile.reverse_results);
bail!("Failed to compile {}", pkg.name);
}
};

let mut compiled = compile(
Expand Down
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/op/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts {
finalized_asm: cmd.print.finalized_asm,
intermediate_asm: cmd.print.intermediate_asm,
ir: cmd.print.ir,
reverse_order: cmd.print.reverse_order,
},
time_phases: cmd.print.time_phases,
minify: pkg::MinifyOpts {
Expand Down
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/op/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts {
finalized_asm: cmd.print.finalized_asm,
intermediate_asm: cmd.print.intermediate_asm,
ir: cmd.print.ir,
reverse_order: cmd.print.reverse_order,
},
minify: pkg::MinifyOpts {
json_abi: cmd.minify.json_abi,
Expand Down
16 changes: 13 additions & 3 deletions forc-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,23 @@ pub fn print_warnings(
));
}

pub fn print_on_failure(terse_mode: bool, warnings: &[CompileWarning], errors: &[CompileError]) {
pub fn print_on_failure(
terse_mode: bool,
warnings: &[CompileWarning],
errors: &[CompileError],
reverse_results: bool,
) {
let e_len = errors.len();
let w_len = warnings.len();

if !terse_mode {
warnings.iter().for_each(format_warning);
errors.iter().for_each(format_err);
if reverse_results {
warnings.iter().rev().for_each(format_warning);
errors.iter().rev().for_each(format_err);
} else {
warnings.iter().for_each(format_warning);
errors.iter().for_each(format_err);
}
}

if e_len == 0 && w_len > 0 {
Expand Down
1 change: 1 addition & 0 deletions forc/src/cli/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::Opts {
finalized_asm: cmd.build.print.finalized_asm,
intermediate_asm: cmd.build.print.intermediate_asm,
ir: cmd.build.print.ir,
reverse_order: cmd.build.print.reverse_order,
},
time_phases: cmd.build.print.time_phases,
minify: pkg::MinifyOpts {
Expand Down
3 changes: 3 additions & 0 deletions forc/src/cli/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub struct Print {
/// Output the time elapsed over each part of the compilation process.
#[clap(long)]
pub time_phases: bool,
/// Output build errors and warnings in reverse order.
#[clap(long)]
pub reverse_order: bool,
}

/// Package-related options.
Expand Down
1 change: 1 addition & 0 deletions forc/src/ops/forc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts {
finalized_asm: cmd.build.print.finalized_asm,
intermediate_asm: cmd.build.print.intermediate_asm,
ir: cmd.build.print.ir,
reverse_order: cmd.build.print.reverse_order,
},
time_phases: cmd.build.print.time_phases,
minify: pkg::MinifyOpts {
Expand Down
1 change: 1 addition & 0 deletions forc/src/ops/forc_contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn build_opts_from_cmd(cmd: &ContractIdCommand) -> pkg::BuildOpts {
finalized_asm: cmd.print.finalized_asm,
intermediate_asm: cmd.print.intermediate_asm,
ir: cmd.print.ir,
reverse_order: cmd.print.reverse_order,
},
time_phases: cmd.print.time_phases,
minify: pkg::MinifyOpts {
Expand Down
1 change: 1 addition & 0 deletions forc/src/ops/forc_predicate_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts {
finalized_asm: cmd.print.finalized_asm,
intermediate_asm: cmd.print.intermediate_asm,
ir: cmd.print.ir,
reverse_order: cmd.print.reverse_order,
},
time_phases: cmd.print.time_phases,
minify: pkg::MinifyOpts {
Expand Down
Loading