Ph0enixKM / Amber

💎 Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.54k stars 70 forks source link

Integrate shfmt #128

Open b1ek opened 1 month ago

b1ek commented 1 month ago

The mechanism can support multiple formatters, and selects the first one available in current environment

Closes #103

arapower commented 1 month ago

I've updated to the latest code with git pull. After installing shfmt locally and running cargo test, I encountered the following errors:

failures:

---- tests::validity::array_init stdout ----
thread 'tests::validity::array_init' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::validity::bool stdout ----
thread 'tests::validity::bool' panicked at src/tests/validity.rs:53:5:
assertion `left == right` failed
  left: ""
 right: "1"

---- tests::validity::add stdout ----
thread 'tests::validity::add' panicked at src/tests/validity.rs:23:5:
assertion `left == right` failed
  left: ""
 right: "60"

failures:
    tests::validity::add
    tests::validity::array_init
    tests::validity::bool

test result: FAILED. 87 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.05s

error: test failed, to rerun pass `--bin amber`

At other times, the following error may occur during execution.

failures:

---- tests::validity::array_assign stdout ----
thread 'tests::validity::array_assign' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }

---- tests::validity::array_init stdout ----
thread 'tests::validity::array_init' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::validity::add_arrays_literal stdout ----
thread 'tests::validity::add_arrays_literal' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }

---- tests::validity::array_assign_out_of_bounds stdout ----
thread 'tests::validity::array_assign_out_of_bounds' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }

---- tests::validity::bool stdout ----
thread 'tests::validity::bool' panicked at src/modules/formatter.rs:57:30:
Couldn't spawn shfmt: Os { code: 2, kind: NotFound, message: "No such file or directory" }

---- tests::validity::add stdout ----
thread 'tests::validity::add' panicked at src/tests/validity.rs:23:5:
assertion `left == right` failed
  left: ""
 right: "60"

failures:
    tests::validity::add
    tests::validity::add_arrays_literal
    tests::validity::array_assign
    tests::validity::array_assign_out_of_bounds
    tests::validity::array_init
    tests::validity::bool

test result: FAILED. 84 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out; finished in 11.92s

error: test failed, to rerun pass `--bin amber`
Ph0enixKM commented 1 month ago

@arapower what is your default shell? It seems that this code doesn't run on bash? Correct me if I'm wrong

arapower commented 1 month ago

@Ph0enixKM I am using Ubuntu on WSL2.

$ echo $SHELL
/bin/bash
Ph0enixKM commented 4 weeks ago

@b1ek btw I was thinking since src/modules is a directory for syntax modules - can we also move the files that are not-related to parsing syntax somewhere else? Like for ex. src/utils.

Beacuse src/modules/formatter.rs is more about formatting the output. I have to add a section about what dir means what in contribution section of README.md

b1ek commented 4 weeks ago

src/modulesis a directory for syntax modules, so should moveformatter.rs` into a different directory

sure, that makes sense

I have to add a section about what dir means what in contribution section of README.md

wouldn't it be better to create a separate guide for contributing in CONTRIBUTING.md?

Ph0enixKM commented 4 weeks ago

Oh yeah. It would. I'll create an issue for that

Ph0enixKM commented 4 weeks ago

I've added a draft issue in our project