Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Mar 26, 2019
1 parent 46c39b4 commit 7372be0
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 44 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# v0.4.0
- Add flags `test` command
- Add flags to `test` command
- `--verbose` will print more detailed output
- `--no-color` will discard all colors
- `--concurrent [int value]` sets the maximum concurrently executed tests in `go routines`
- Add default test concurrency of `runtime.NumCPU() * 5`
- Add default test concurrency to `runtime.NumCPU() * 5`

# v0.3.0

Expand Down
83 changes: 43 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@

Define `YAML` based test suites for your command line applications.

- [Quick start](#quick-start)
- [Installation](#installation)
* [Linux & osx](#linux---osx)
* [Windows](#windows)
- [Example](#example)
- [Minimal test](#minimal-test)
- [Usage](#usage)
- [Development](#development)

## Quick start

- [Install](#installation) `commander` and it to your `path`
- Create a `commander.yaml` in your project root
- Add a test [Minimal test](#minimal-test)
- Run `./commander test`

For more information take a look at the [manual](docs/manual.md), the [examples](examples) or the [integration tests](integration).

## Installation

### Linux & osx

```bash
# Install latest version to /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/SimonBaeumer/commander/master/install.sh | sh
Expand All @@ -18,21 +38,39 @@ curl -fsSL https://raw.githubusercontent.com/SimonBaeumer/commander/master/insta
curl -fsSL https://raw.githubusercontent.com/SimonBaeumer/commander/master/install.sh | COMMANDER_VER=v0.1.0 COMMANDER_DST=~/bin sh
```

### Windows

- Download the current [release](https://github.com/SimonBaeumer/commander/releases/latest)
- Add the path to your [path](https://docs.alfresco.com/4.2/tasks/fot-addpath.html) environment variable
- Test it: `commander --version`

## Example

You can find more examples in `examples/`

```
# Build the project
$ make build
# Execute testsuite
$ ./commander test examples/commander.yaml
# Execute test suite
Starting test file examples/commander.yaml...
✓ it should exit with error code
✓ it should print hello world
✓ echo hello
✓ it should validate exit code
✓ it should fail
Duration: 0.005s
Count: 2, Failed: 0
Count: 4, Failed: 0
```

## Minimal test

```yaml
tests:
echo hello:
stdout: hello
exit-code: 0
```
## Usage
Expand All @@ -49,46 +87,11 @@ COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--verbose More output for debugging [$COMMANDER_VERBOSE]
--help, -h show help
--version, -v print the version
```

## Example yaml file

```
config:
env:
ENV_KEY: value
dir: /tmp #set the current working dir
tests:
it will print hello world:
cmd: echo hello world
stdout:
lines:
1: hello world
contains:
- hello world
exactly: hello world
exit-code: 0
it will print hello:
cmd: echo hello
stdout: hello
exit-code: 0
it prints variable:
cmd: echo $ENV_KEY
stdout: value
exit-code: 0
it overwrites dir:
cmd: pwd
config:
dir: /home/commander
stdout: /home/commander
exit-code: 0
```


## Development

Expand Down
44 changes: 44 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Manual

`commander` will automatically search for a `commander.yaml` in the current working directory.

## Tests

```yaml
config: # Config for all tests
dir: /tmp #Set working directory
env: # Environment variables
KEY: global
timeout: 5000 #Timeout in ms

tests:
echo hello: # Define command as title
stdout: hello # Default is to check if it contains the given characters
exit-code: 0 # Assert exit-code

it should fail:
command: invalid
stderr:
contains:
- invalid # Assert only contain work
exactly: "/bin/sh: 1: invalid: not found"
line-count: 1 # Assert amount of lines
lines: # Assert specific lines
1: "/bin/sh: 1: invalid: not found"
exit-code: 127

it has configs:
command: echo hello
stdout:
contains:
- hello #See test "it should fail"
exactly: hello
line-count: 1
config:
dir: /home/user # Overwrite working dir
env:
KEY: local # Overwrite env variable
ANOTHER: yeah # Add another env variable
timeout: 1000 # Overwrite timeout
exit-code: 0
```
18 changes: 16 additions & 2 deletions examples/commander.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ tests:
command: echo hello world
stdout: hello world
exit-code: 0
it should exit with error code:

it should validate exit code:
command: exit 1
exit-code: 1
exit-code: 1

echo hello: #Use title as command
stdout:
exactly: hello
line-count: 1
lines:
1: hello
exit-code: 0

it should fail:
command: invalid
stderr: "/bin/sh: 1: invalid: not found"
exit-code: 127
15 changes: 15 additions & 0 deletions examples/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
config:
env:
KEY: global
tests:
echo $KEY:
stdout: global
exit-code: 0

it should overwrite env:
command: echo $KEY
stdout: local
config:
env:
KEY: local
exit-code: 0
3 changes: 3 additions & 0 deletions examples/minimal_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests:
echo hello:
exit-code: 0

0 comments on commit 7372be0

Please sign in to comment.