diff options
Diffstat (limited to 'tamer')
-rw-r--r-- | tamer/Makefile.am | 10 | ||||
-rw-r--r-- | tamer/README.md | 31 | ||||
-rw-r--r-- | tamer/configure.ac | 9 |
3 files changed, 48 insertions, 2 deletions
diff --git a/tamer/Makefile.am b/tamer/Makefile.am index 2cc502c..3248bc6 100644 --- a/tamer/Makefile.am +++ b/tamer/Makefile.am @@ -18,7 +18,7 @@ .DELETE_ON_ERROR: -.PHONY: all +.PHONY: all fix fmt CARGO_BUILD_FLAGS=@CARGO_BUILD_FLAGS@ @@ -31,6 +31,12 @@ html-am: # note that 'cargo check' is something else; see 'cargo --help' test: check -check-am: +check-am: check-fmt @CARGO@ test +check-fmt: + @CARGO@ fmt -- --check + +fix: fmt +fmt: + @CARGO@ fmt diff --git a/tamer/README.md b/tamer/README.md index 6d44f02..2d14ef4 100644 --- a/tamer/README.md +++ b/tamer/README.md @@ -47,3 +47,34 @@ $ ./configure CARGO_BUILD_FLAGS=--release && make $ ./configure && make $ ./configure CARGO_BUILD_FLAGS=--release && make CARGO_BUILD_FLAGS= ``` + + +## Hacking +This section contains advice for those developing TAMER. + + +### Running Tests +Developers should be using test-driven development (TDD). `make check` will +run all necessary tests. + + +### Code Format +Rust provides `rustfmt` that can automatically format code for you. This +project mandates its use and therefore eliminates personal preference in +code style (for better or worse). + +Formatting checks are run during `make check` and, on failure, will output +the diff that would be applied if you ran `make fmt` (or `make fix`); this +will run `cargo fmt` for you (and will use the binaries configured via +`configure`). + +Since developers should be doing test-driven development (TDD) and therefore +should be running `make check` frequently, the hope is that frequent +feedback on formatting issues will allow developers to quickly adjust their +habits to avoid triggering formatting errors at all. + +If you want to automatically fix formatting errors and then run tests: + +```sh +$ make fmt check +``` diff --git a/tamer/configure.ac b/tamer/configure.ac index 9ed3526..350b77b 100644 --- a/tamer/configure.ac +++ b/tamer/configure.ac @@ -55,6 +55,15 @@ AX_COMPARE_VERSION([$rustc_version], [ge], [$rustc_ver_req], AC_ARG_VAR([CARGO_BUILD_FLAGS], [Flags to be passed to `cargo build' when invoked via Make]) +# Cargo commands may be available but not necessarily installed for the +# active toolchain. Let's check that. +AC_MSG_CHECKING([whether cargo-fmt is available for active toolchain]) +AS_IF([cargo fmt --help &>/dev/null], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + cargo fmt --help # run again so user can see output + AC_MSG_ERROR([missing cargo-fmt for active toolchain])]) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT |