File: TESTS.md

package info (click to toggle)
powerlevel9k 0.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 784 kB
  • sloc: sh: 4,498; makefile: 5
file content (69 lines) | stat: -rw-r--r-- 2,269 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Tests

## Automated Tests

The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself,
but we try to reflect the structure as much as possible. All tests are located
under `test/`. Segment specific tests under `test/segments/` (one file per
segment).

### Installation

In order to execute the tests you need to install `shunit2`, which is a
submodule. To install the submodule, you can execute 
`git submodule init && git submodule update`.

### Executing tests

The tests are shell scripts on their own. So you can execute them right away.
To execute all tests you could just execute `./test/suite.spec`.

### General Test Structure

The tests usually have a `setUp()` function which is executed before every
test function. Speaking of, test functions must be prefixed with `test`. In
the tests, you can do [different Assertions](https://github.com/kward/shunit2#-asserts).
It is always a good idea to mock the program you want to test (just have a
look at other tests), so that the testrunner does not have to have all
programs installed.

### Travis

We use [Travis](https://travis-ci.org/) for Continuous Integration. This
service executes our tests after every push. For now, we need to tell travis
where to find the tests, which is what happens in the `.travis.yml` file.

## Manual Testing

If unit tests are not sufficient (e.g. you have an issue with your prompt that
occurs only in a specific ZSH framework) then you can use either Docker or
or our Vagrant.

### Docker

This is the easiest to use _if_ you have Docker already installed and running.

The command `./test-in-docker` should make it fairly easy to get into a running
container with the framework of your choice.

Examples:

``` zsh
# Test Antigen with the oldest version of ZSH
$ ./test-in-docker antigen
```

``` zsh
# Test Prezto with ZSH version 5.2
$ ./test-in-docker --zsh 5.2 prezto
```

You can get Docker at <https://www.docker.com/community-edition>.

**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS).

### Vagrant

Currently there are two test VMs. `test-vm` is an Ubuntu machine with several
pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD!
For how to run the machines see [here](test-vm/README.md).