Skip to content

Commit

Permalink
Add doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichRober committed Dec 14, 2023
1 parent 42d0107 commit 175db2e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dev/tests_doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Introduction
The files in this directory are used to post-process test files
that are extracted from the documentation examples.

# Main Files
- `processTests.sh` : processes all doc tests and moves them into `tst/files/doc`.

# Instructions
In order to post-process the tests and move them into `tst/files/doc` automatically, one needs to execute `processTests.sh` from any place.
37 changes: 37 additions & 0 deletions dev/tests_doc/processTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# go to root of repo
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $script_dir/../..
echo "Working in folder $(pwd)"

# get operating system
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac


# Post-processing for the extracted examples from the documentation.
# - Add a "\n" to all Print executions.
# - Move files into test_dir
test_dir="tst/files/doc"
mkdir -p $test_dir
files=($(ls -1 tst/lins*.tst))
echo "Found ${#files[@]} test file(s)"
for file in ${files[@]}; do
echo "Processing $file"
if [ "${machine}" == "Mac" ]; then
sed -i "" 's|Print(\(.*\));|Print(\1, \"\\n\");|g' $file
elif [ "${machine}" == "Linux" ]; then
sed -i 's|Print(\(.*\));|Print(\1, \"\\n\");|g' $file
else
echo "ERROR: Unsupported operating system ${machine}"
exit 1
fi;
mv $file $test_dir/${file#"tst/"}
done
1 change: 1 addition & 0 deletions makedoc.g
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ AutoDoc( rec( scaffold := rec(
"license.xml",
],
),
extract_examples := true,
autodoc := true ) );

0 comments on commit 175db2e

Please sign in to comment.