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

Report formatter output on error #104

Merged
merged 1 commit into from
Apr 11, 2021
Merged

Report formatter output on error #104

merged 1 commit into from
Apr 11, 2021

Conversation

basile-henry
Copy link
Contributor

fixes #103

Show stdout and stderr of the formatter when it errors out.

To simulate a formatter error I have been using:

diff --git a/treefmt.toml b/treefmt.toml
index 2b5fb94..99f55e6 100644
--- a/treefmt.toml
+++ b/treefmt.toml
@@ -1,7 +1,8 @@
 # One CLI to format the code tree - https://github.com/numtide/treefmt

 [formatter.python]
-command = "black"
+command = "bash"
+options = ["-c", "echo $1; >&2 echo This is an error; exit 1", "--"]
 includes = ["*.py"]

 [formatter.elm]

This results in the following output:

🐛 [DEBUG]: Error using formatter #python:
• [STDOUT]:
/home/basile/dev/treefmt/examples/python/main.py

• [STDERR]:
This is an error

ℹ️ [INFO]: #elm: 1 files processed in 38.89ms
ℹ️ [INFO]: #rust: 13 files processed in 73.00ms
⛔ [ERR]: #python's formatter failed: exit status 1

@github-actions
Copy link
Contributor

🤠 Cargo bloat for toolchain stable-x86_64-unknown-linux-gnu 🤠

@@ Size breakdown @@

Size       1.67 MB
Text size  1.67 MB

No changes to crate sizes

Dependency tree
@@ Dependency tree @@
Count: 145

├─ anyhow v1.0.38
├─ console v0.13.0
│  ├─ lazy_static v1.4.0
│  ├─ libc v0.2.86
│  ├─ regex v1.4.3
│  │  ├─ aho-corasick v0.7.15
│  │  │  └─ memchr v2.3.4
│  │  ├─ memchr v2.3.4
│  │  ├─ regex-syntax v0.6.22
│  │  └─ thread_local v1.1.3
│  │     └─ once_cell v1.5.2
│  ├─ terminal_size v0.1.16
│  │  └─ libc v0.2.86
│  └─ unicode-width v0.1.8
├─ directories v3.0.1
│  └─ dirs-sys v0.3.5
│     └─ libc v0.2.86
├─ filetime v0.2.14
│  ├─ cfg-if v1.0.0
│  └─ libc v0.2.86
├─ globset v0.4.6
│  ├─ aho-corasick v0.7.15 
│  ├─ bstr v0.2.15
│  │  ├─ lazy_static v1.4.0
│  │  ├─ memchr v2.3.4
│  │  ├─ regex-automata v0.1.9
│  │  │  └─ byteorder v1.4.2
│  │  └─ serde v1.0.123
│  │     └─ serde_derive v1.0.123 (proc-macro)
│  │        ├─ proc-macro2 v1.0.24
│  │        │  └─ unicode-xid v0.2.1
│  │        ├─ quote v1.0.9
│  │        │  └─ proc-macro2 v1.0.24 
│  │        └─ syn v1.0.60
│  │           ├─ proc-macro2 v1.0.24 
│  │           ├─ quote v1.0.9 
│  │           └─ unicode-xid v0.2.1
│  ├─ fnv v1.0.7
│  ├─ log v0.4.14
│  │  └─ cfg-if v1.0.0
│  └─ regex v1.4.3 
├─ ignore v0.4.17
│  ├─ crossbeam-utils v0.8.1
│  │  ├─ cfg-if v1.0.0
│  │  ├─ lazy_static v1.4.0
│  │  └─ autocfg v1.0.1
│  ├─ globset v0.4.6 
│  ├─ lazy_static v1.4.0
│  ├─ log v0.4.14 
│  ├─ memchr v2.3.4
│  ├─ regex v1.4.3 
│  ├─ same-file v1.0.6
│  ├─ thread_local v1.1.3 
│  └─ walkdir v2.3.1
│     └─ same-file v1.0.6
├─ log v0.4.14 
├─ path-clean v0.1.0
├─ rayon v1.5.0
│  ├─ crossbeam-deque v0.8.0
│  │  ├─ cfg-if v1.0.0
│  │  ├─ crossbeam-epoch v0.9.1
│  │  │  ├─ cfg-if v1.0.0
│  │  │  ├─ const_fn v0.4.5 (proc-macro)
│  │  │  ├─ crossbeam-utils v0.8.1 
│  │  │  ├─ lazy_static v1.4.0
│  │  │  ├─ memoffset v0.6.1
│  │  │  │  └─ autocfg v1.0.1
│  │  │  └─ scopeguard v1.1.0
│  │  └─ crossbeam-utils v0.8.1 
│  ├─ either v1.6.1
│  ├─ rayon-core v1.9.0
│  │  ├─ crossbeam-channel v0.5.0
│  │  │  ├─ cfg-if v1.0.0
│  │  │  └─ crossbeam-utils v0.8.1 
│  │  ├─ crossbeam-deque v0.8.0 
│  │  ├─ crossbeam-utils v0.8.1 
│  │  ├─ lazy_static v1.4.0
│  │  └─ num_cpus v1.13.0
│  │     └─ libc v0.2.86
│  └─ autocfg v1.0.1
├─ serde v1.0.123 
├─ serde_json v1.0.62
│  ├─ itoa v0.4.7
│  ├─ ryu v1.0.5
│  └─ serde v1.0.123 
├─ sha-1 v0.9.3
│  ├─ block-buffer v0.9.0
│  │  └─ generic-array v0.14.4
│  │     ├─ typenum v1.12.0
│  │     └─ version_check v0.9.2
│  ├─ cfg-if v1.0.0
│  ├─ cpuid-bool v0.1.2
│  ├─ digest v0.9.0
│  │  └─ generic-array v0.14.4 
│  └─ opaque-debug v0.3.0
├─ structopt v0.3.21
│  ├─ clap v2.33.3
│  │  ├─ ansi_term v0.11.0
│  │  ├─ atty v0.2.14
│  │  │  └─ libc v0.2.86
│  │  ├─ bitflags v1.2.1
│  │  ├─ strsim v0.8.0
│  │  ├─ textwrap v0.11.0
│  │  │  └─ unicode-width v0.1.8
│  │  ├─ unicode-width v0.1.8
│  │  └─ vec_map v0.8.2
│  ├─ lazy_static v1.4.0
│  └─ structopt-derive v0.4.14 (proc-macro)
│     ├─ heck v0.3.2
│     │  └─ unicode-segmentation v1.7.1
│     ├─ proc-macro-error v1.0.4
│     │  ├─ proc-macro-error-attr v1.0.4 (proc-macro)
│     │  │  ├─ proc-macro2 v1.0.24 
│     │  │  ├─ quote v1.0.9 
│     │  │  └─ version_check v0.9.2
│     │  ├─ proc-macro2 v1.0.24 
│     │  ├─ quote v1.0.9 
│     │  ├─ syn v1.0.60 
│     │  └─ version_check v0.9.2
│     ├─ proc-macro2 v1.0.24 
│     ├─ quote v1.0.9 
│     └─ syn v1.0.60 
├─ tempfile v3.2.0
│  ├─ cfg-if v1.0.0
│  ├─ libc v0.2.86
│  ├─ rand v0.8.3
│  │  ├─ libc v0.2.86
│  │  ├─ rand_chacha v0.3.0
│  │  │  ├─ ppv-lite86 v0.2.10
│  │  │  └─ rand_core v0.6.2
│  │  │     └─ getrandom v0.2.2
│  │  │        ├─ cfg-if v1.0.0
│  │  │        └─ libc v0.2.86
│  │  └─ rand_core v0.6.2 
│  └─ remove_dir_all v0.5.3
├─ toml v0.5.8
│  └─ serde v1.0.123 
└─ which v4.0.2
   ├─ libc v0.2.86
   └─ thiserror v1.0.23
      └─ thiserror-impl v1.0.23 (proc-macro)
         ├─ proc-macro2 v1.0.24 
         ├─ quote v1.0.9 
         └─ syn v1.0.60 

Commit: 356ee8b (Compare with baseline commit)

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@zimbatm zimbatm merged commit 63c58e4 into master Apr 11, 2021
@zimbatm zimbatm deleted the formatter-err-output branch April 11, 2021 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print formatter outputs in debug mode.
2 participants