Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Ignore test output, but keep the directory
/tests/_output/*
!/tests/_output/.gitkeep

# Ignore the compiled program
/zunit
7 changes: 5 additions & 2 deletions .guardian.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
files: ./tests/**/*
run: zunit
files: ./tests/**/*.zunit
run: ./zunit
---
files: ./src/**/*.zsh
run: ./build.zsh && ./zunit
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ before_script:
- chmod u+x .bin/{color,revolver,zvm}
- export PATH="$HOME/.zvm/bin:$PWD/.bin:$PATH"
- zvm use ${ZVM_VERSION}
- ./build.zsh
script: ./zunit
notifications:
email: false
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ ZUnit is a powerful unit testing framework for ZSH
zulu install zunit
```

### zplug
> **NOTE:** In versions of Zulu prior to `1.2.0`, there is an additional step required after install:

```sh
zplug "molovo/zunit", \
as:command, \
use:zunit
```
```sh
cd ~/.zulu/packages/zunit
./build.zsh
zulu link zunit
```

### Manual

```sh
git clone https://github.com/molovo/zunit
cd ./zunit
./build.zsh
chmod u+x ./zunit
cp ./zunit /usr/local/bin
```

> For best results, the utilities [Color](https://github.com/molovo/color) and [Revolver](https://github.com/molovo/revolver) should be installed, and in your `$PATH`. The zulu installation method will install these dependencies for you.
> ZUnit requires the utilities [Color](https://github.com/molovo/color) and [Revolver](https://github.com/molovo/revolver) to be installed, and in your `$PATH`. The zulu installation method will install these dependencies for you.

## Writing Tests

Expand Down Expand Up @@ -380,8 +381,12 @@ zunit
# Runs all test files in ./other_tests
zunit other_tests

# Runs all tests in the file ./tests/a-test-file
zunit tests/a-test-file
# Runs all tests in the file ./tests/a-test-file.zunit
zunit tests/a-test-file.zunit

# Runs a single test named 'The name of the test' in the file
# ./tests/a-test-file.zunit
zunit tests/a-test-file.zunit@'The name of the test'

# Runs all tests, and exists immediately after the first failure
zunit --fail-fast
Expand Down
23 changes: 23 additions & 0 deletions build.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env zsh

# Clear the file to start with
cat /dev/null > zunit

# Start with the shebang
echo "#!/usr/bin/env zsh\n" >> zunit

# We need to do some fancy globbing
setopt EXTENDED_GLOB

# Print each of the source files into the target, removing any comments
# and blank lines from the compiled executable
cat src/**/(^zunit).zsh | grep -v -E '^(\s*#.*[^"]|\s*)$' >> zunit

# Print the main command last
cat src/zunit.zsh | grep -v -E '^(\s*#.*[^"]|\s*)$' >> zunit

# Make sure the file is executable
chmod u+x zunit

# Let the user know we're finished
echo "\033[0;32m✔\033[0;m ZUnit built successfully"
Loading