Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All contributions are generally welcome as long as they fit in with the concepts

# Code Rules

All code must adhere to the [RULES.dm](RULES.md) and mostly follows the [Google style](https://google.github.io/styleguide/). Where it diverges, clang-tidy rules are in effect as much as possible.
All code must adhere to the [RULES.md](RULES.md) and mostly follows the [Google style](https://google.github.io/styleguide/). Where it diverges, clang-tidy rules are in effect as much as possible.

# Run pre-commit

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ locally or with `--sandbox_debug`.
* scratch helper `test_tmpdir [name]`: Creates and prints a unique directory below `${BASHTEST_TMPDIR}`.
* expectation `expect_eq` "\${LHS}" "\${RHS}": Asserts that two strings are the same.
* expectation `expect_ne` "\${LHS}" "\${RHS}": Asserts that two strings are different.
* expectation `expect_files_eq` "\${LHS}" "\${RHS}": Asserts that two file are the same (supports golden updates).
* expectation `expect_files_eq` "\${LHS}" "\${RHS}": Asserts that two files are the same (supports golden updates).
* expectation `expect_contains` "\${EXPECTED}" "\${ARRAY[@]}": Assert that one string is present in an array.
* expectation `expect_not_contains` "\${EXPECTED}" "\${ARRAY[@]}": Assert that one string is not present in an array.
* expectation `expect_output_contains` "\${SUBSTRING}" "\${TEXT}": Assert that a text contains a literal substring.
Expand Down
4 changes: 2 additions & 2 deletions RULES.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Some rules for the code layout and its development.

* Everything is under Apache 2 license, see fle `LICENSE`.
* Everything is under Apache 2 license, see file `LICENSE`.
* All sources must be unix-text files: https://en.wikipedia.org/wiki/Text_file
* Lines end in {LF}.
* The files are either empty or end in {LF}.
* All exported library code is in the directory 'bashtest'.
* No namespace may be named 'internal'.
* All public / exported code must:
* be tested,
* have a documentaion.
* have documentation.
* API changes that are not backwards compatible should not occur in minor version changes.
* Undocumented and private/internal APIs may be changed in any way at any time.
6 changes: 4 additions & 2 deletions bashtest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Bashtest provides `sh_test` wrapper that simplifies the creation of shell tests.


* bashtest:bashtest, bashtest/bashtest.sh
* sh_library `bashtest.sh` which provides a test runner for complex shell tests involving golden files that provides built-in golden update functionality (see `bazel run //bashtest:bashtest_help`).
* sh_library `bashtest_sh` which provides a test runner for complex shell tests involving golden files that provides built-in golden update functionality (see `bazel run //bashtest:bashtest_help`).
* status helper `test_has_error`: Returns whether a test function has had an expectation error. This is reset for every test function.
* status helper `test_has_failed_tests`: Returns whether a test program had previous failing test functions.
* scratch helper `test_tmpdir [name]`: Creates and prints a unique directory below `${BASHTEST_TMPDIR}`.
* expectation `expect_eq` "\${LHS}" "\${RHS}": Asserts that two strings are the same.
* expectation `expect_ne` "\${LHS}" "\${RHS}": Asserts that two strings are different.
* expectation `expect_files_eq` "\${LHS}" "\${RHS}": Asserts that two file are the same (supports golden updates).
* expectation `expect_files_eq` "\${LHS}" "\${RHS}": Asserts that two files are the same (supports golden updates).
* expectation `expect_contains` "\${EXPECTED}" "\${ARRAY[@]}": Assert that one string is present in an array.
* expectation `expect_not_contains` "\${EXPECTED}" "\${ARRAY[@]}": Assert that one string is not present in an array.
* expectation `expect_output_contains` "\${SUBSTRING}" "\${TEXT}": Assert that a text contains a literal substring.
Expand All @@ -18,5 +19,6 @@ Bashtest provides `sh_test` wrapper that simplifies the creation of shell tests.
* expectation `expect_not_matches` "\${REGEX}" "\${TEXT}": Assert that a text does not match an extended regular expression.
* expectation `expect_pcre_matches` "\${REGEX}" "\${TEXT}": Assert that a text matches a Perl Compatible Regular Expression (requires an external PCRE tool).
* expectation `expect_pcre_not_matches` "\${REGEX}" "\${TEXT}": Assert that a text does not match a Perl Compatible Regular Expression.
* control `skip_test` "\${REASON}": Marks the current test as skipped and reports the reason. Use `skip_test "reason" && return` to end the test body.
* special test function `test::test_init`: If present, then this function runs first! Tests will only be executed if it succeeds.
* special test function `test::test_done`: If present, then this function runs last!
6 changes: 3 additions & 3 deletions bashtest/bashtest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ load("@rules_shell//shell:sh_test.bzl", "sh_test")
# Resolve the bashtest runtime relative to *this* module's repository. A `Label`
# constructed in a `.bzl` file is resolved against the repo that defines the
# file, so the macro works no matter what apparent repo name a consumer assigns
# it (and under both bzlmod and the legacy WORKSPACE setup). This is what lets
# the module to work without an apparent repository-name alias.
# it through bzlmod. This lets the module work without an apparent
# repository-name alias.
_BASHTEST_SH = Label("//bashtest:bashtest_sh")

def bashtest(
Expand All @@ -31,7 +31,7 @@ def bashtest(
**kwargs):
"""Bashtest wrapper.

Specialized `sh_shell` rule to simplify `bashtest` usage. The rule provides
Specialized `sh_test` rule to simplify `bashtest` usage. The rule provides
the `mboworks_bashtest` environment variable that should
be used in test scripts to source the `bashtest.sh` script as follows:

Expand Down
Loading