Skip to content

Commit 0f45f41

Browse files
committed
Added basic script to use for formatting tests
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
1 parent 4207ed2 commit 0f45f41

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ __pycache__
88
.DS_STORE
99
.pytest_cache
1010
/out/
11+
/tmp/
12+
*.log

tests/run-formatting-tests.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#/usr/bin/env bash
2+
set -e
3+
# set -x
4+
5+
echo "These tests expect cfengine CLI to be installed globally or in venv"
6+
7+
echo "Looking for CFEngine CLI:"
8+
which cfengine
9+
10+
echo "Check that input and expected files exist:"
11+
ls -al tests/format/*.input.cf
12+
ls -al tests/format/*.expected.cf
13+
14+
mkdir -p tmp
15+
16+
echo "Check that input files match expected files:"
17+
ls tests/format/*.input.cf > tmp/format-input-files.log
18+
ls tests/format/*.expected.cf > tmp/format-expected-files.log
19+
sed s/.input.cf/.cf/g tmp/format-input-files.log > tmp/a.log
20+
sed s/.expected.cf/.cf/g tmp/format-expected-files.log > tmp/b.log
21+
diff -u tmp/a.log tmp/b.log
22+
23+
echo "Run formatting tests:"
24+
for file in tests/format/*.input.cf; do
25+
expected="$(echo $file | sed s/.input.cf/.expected.cf/g)"
26+
output="$(echo $file | sed s/.input.cf/.output.cf/g)"
27+
echo "TODO: Implement formatting on stdin / stdout in cfengine format"
28+
cat $file | cfengine format - > $output
29+
diff -u $expected $output
30+
echo "OK: $file - $expected"
31+
done
32+
33+
echo "All formatting tests successful!"

0 commit comments

Comments
 (0)