Skip to content

Commit c5c2f21

Browse files
Vampiretnyblom
authored andcommitted
Add Bats tests
1 parent cac4fde commit c5c2f21

File tree

28 files changed

+248
-1
lines changed

28 files changed

+248
-1
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
qtbase5-dev
3838
3939
- name: 'Checkout Git branch'
40-
uses: actions/checkout@v2.0.0
40+
uses: actions/checkout@v2
41+
with:
42+
submodules: true
4143

4244
- name: 'Configure'
4345
run: |-
@@ -47,6 +49,10 @@ jobs:
4749
run: |-
4850
make
4951
52+
- name: 'Test'
53+
run: |-
54+
./test.sh --no-make
55+
5056
- name: 'Install'
5157
run: |-
5258
set -e

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ Makefile
22
*~
33
*.o
44
svn-all-fast-export
5+
svn-all-fast-export.exe
56
src/local-config.pri
7+
/build/

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "test/libs/bats-core"]
2+
path = test/libs/bats-core
3+
url = https://github.com/bats-core/bats-core
4+
[submodule "test/libs/bats-assert"]
5+
path = test/libs/bats-assert
6+
url = https://github.com/bats-core/bats-assert
7+
[submodule "test/libs/bats-support"]
8+
path = test/libs/bats-support
9+
url = https://github.com/bats-core/bats-support
10+
[submodule "test/libs/bats-file"]
11+
path = test/libs/bats-file
12+
url = https://github.com/tralston/bats-file

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ Run `qmake && make`. You get `./svn-all-fast-export`.
3333
You will need to have some packages to compile it. For Ubuntu distros, use this command to install them all:
3434
`sudo apt-get install build-essential subversion git qtchooser qt5-default libapr1 libapr1-dev libsvn-dev`
3535

36+
To run all tests you can simply call the `test.sh` script in the root directory.
37+
This will run all [Bats](https://github.com/bats-core/bats-core) based tests
38+
found in `.bats` files in the directory `test`. Running the script will automatically
39+
execute `qmake` and `make` first to build the current code if necessary.
40+
If you want to run tests without running make, you can give `--no-make` as first parameter.
41+
If you want to only run a subset of the tests, you can specify the base-name of one
42+
or multiple `.bats` files to only run these tests like `./test.sh command-line svn-ignore`.
43+
If you want to investigate the temporary files generated during a test run,
44+
you can set the environment variables `BATSLIB_TEMP_PRESERVE=1` or `BATSLIB_TEMP_PRESERVE_ON_FAILURE=1`.
45+
So if for example some test in `svn-ignore.bats` failed, you can investigate the failed case like
46+
`BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 ./test.sh --no-make svn-ignore` and then look
47+
in `build/tmp` to investigate the situation.
48+
3649
KDE
3750
---
3851
there is a repository kde-ruleset which has several example files and one file that should become the final ruleset for the whole of KDE called 'kde-rules-main'.

test.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Ensure needed tools are present
6+
svn --version >/dev/null
7+
git --version >/dev/null
8+
9+
# Determine SCRIPT_DIR
10+
# Resolve links: $0 may be a link
11+
PRG="$0"
12+
# Need this for relative symlinks.
13+
while [ -h "$PRG" ]; do
14+
ls=$(ls -ld "$PRG")
15+
link=$(expr "$ls" : '.*-> \(.*\)$')
16+
if expr "$link" : '/.*' >/dev/null; then
17+
PRG="$link"
18+
else
19+
PRG=$(dirname "$PRG")"/$link"
20+
fi
21+
done
22+
cd "$(dirname "$PRG")/" >/dev/null
23+
SCRIPT_DIR="$(pwd -P)"
24+
25+
if [ "${1-}" == "--no-make" ]; then
26+
shift
27+
else
28+
qmake
29+
make
30+
fi
31+
32+
if [ $# -eq 0 ]; then
33+
set -- test
34+
else
35+
set -- "${@/#/test/}"
36+
set -- "${@/%/.bats}"
37+
fi
38+
39+
mkdir -p "$SCRIPT_DIR/build/tmp"
40+
TMPDIR="$SCRIPT_DIR/build/tmp" test/libs/bats-core/bin/bats "$@"

test/base-fixture/README.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This is a Subversion repository; use the 'svnadmin' and 'svnlook'
2+
tools to examine it. Do not add, delete, or modify files here
3+
unless you know how to avoid corrupting the repository.
4+
5+
Visit http://subversion.apache.org/ for more information.

test/base-fixture/db/current

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

test/base-fixture/db/format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
7
2+
layout sharded 1000
3+
addressing logical

test/base-fixture/db/fs-type

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fsfs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

0 commit comments

Comments
 (0)