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 591eaf1 commit d5df4a5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
GAPBRANCH: ${{ matrix.gap-branch }}
GAP_PKGS_TO_BUILD: "io profiling grape cohomolo"
- uses: gap-actions/build-pkg@v1
- uses: gap-actions/build-pkg-docs@v1
- uses: gap-actions/run-pkg-tests@v2
- uses: gap-actions/process-coverage@v2
- uses: codecov/codecov-action@v3
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@

/gh-pages/

_dev
_dev

/tst/files/doc/
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
3 changes: 3 additions & 0 deletions makedoc.g
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ AutoDoc( rec( scaffold := rec(
"license.xml",
],
),
extract_examples := true,
autodoc := true ) );

Exec("dev/tests_doc/processTests.sh");

0 comments on commit d5df4a5

Please sign in to comment.