1*da0073e9SAndroid Build Coastguard Worker#!/bin/bash 2*da0073e9SAndroid Build Coastguard Worker__doc__=" 3*da0073e9SAndroid Build Coastguard WorkerThis script simply runs the torch doctests via the xdoctest runner. 4*da0073e9SAndroid Build Coastguard Worker 5*da0073e9SAndroid Build Coastguard WorkerThis must be run from the root of the torch repo, as it needs the path to the 6*da0073e9SAndroid Build Coastguard Workertorch source code. 7*da0073e9SAndroid Build Coastguard Worker 8*da0073e9SAndroid Build Coastguard WorkerThis script is provided as a developer convenience. On the CI the doctests are 9*da0073e9SAndroid Build Coastguard Workerinvoked in 'run_test.py' 10*da0073e9SAndroid Build Coastguard Worker" 11*da0073e9SAndroid Build Coastguard Worker# To simply list tests 12*da0073e9SAndroid Build Coastguard Worker# xdoctest -m torch --style=google list 13*da0073e9SAndroid Build Coastguard Worker 14*da0073e9SAndroid Build Coastguard Worker# Reference: https://stackoverflow.com/questions/59895/bash-script-dir 15*da0073e9SAndroid Build Coastguard WorkerSCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 16*da0073e9SAndroid Build Coastguard WorkerTORCH_MODPATH=$SCRIPT_DIR/../torch 17*da0073e9SAndroid Build Coastguard Workerecho "TORCH_MODPATH = $TORCH_MODPATH" 18*da0073e9SAndroid Build Coastguard Worker 19*da0073e9SAndroid Build Coastguard Workerif [[ ! -d "$TORCH_MODPATH" ]] ; then 20*da0073e9SAndroid Build Coastguard Worker echo "Could not find the path to the torch module" 21*da0073e9SAndroid Build Coastguard Workerelse 22*da0073e9SAndroid Build Coastguard Worker export XDOCTEST_GLOBAL_EXEC="from torch import nn\nimport torch.nn.functional as F\nimport torch" 23*da0073e9SAndroid Build Coastguard Worker export XDOCTEST_OPTIONS="+IGNORE_WHITESPACE" 24*da0073e9SAndroid Build Coastguard Worker # Note: google wont catch numpy style docstrings (a few exist) but it also wont fail 25*da0073e9SAndroid Build Coastguard Worker # on things not intended to be doctests. 26*da0073e9SAndroid Build Coastguard Worker export XDOCTEST_STYLE="google" 27*da0073e9SAndroid Build Coastguard Worker xdoctest torch "$TORCH_MODPATH" --style="$XDOCTEST_STYLE" --global-exec "$XDOCTEST_GLOBAL_EXEC" --options="$XDOCTEST_OPTIONS" 28*da0073e9SAndroid Build Coastguard Workerfi 29