forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_doctests.sh
executable file
·28 lines (24 loc) · 1.11 KB
/
run_doctests.sh
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
#!/bin/bash
__doc__="
This script simply runs the torch doctests via the xdoctest runner.
This must be run from the root of the torch repo, as it needs the path to the
torch source code.
This script is provided as a developer convenience. On the CI the doctests are
invoked in 'run_test.py'
"
# To simply list tests
# xdoctest -m torch --style=google list
# Reference: https://stackoverflow.com/questions/59895/bash-script-dir
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TORCH_MODPATH=$SCRIPT_DIR/../torch
echo "TORCH_MODPATH = $TORCH_MODPATH"
if [[ ! -d "$TORCH_MODPATH" ]] ; then
echo "Could not find the path to the torch module"
else
export XDOCTEST_GLOBAL_EXEC="from torch import nn\nimport torch.nn.functional as F\nimport torch"
export XDOCTEST_OPTIONS="+IGNORE_WHITESPACE"
# Note: google wont catch numpy style docstrings (a few exist) but it also wont fail
# on things not intended to be doctests.
export XDOCTEST_STYLE="google"
xdoctest torch "$TORCH_MODPATH" --style="$XDOCTEST_STYLE" --global-exec "$XDOCTEST_GLOBAL_EXEC" --options="$XDOCTEST_OPTIONS"
fi