@@ -50,20 +50,36 @@ if [[ "${INJECT_REGION_TAGS:-}" == "true" ]]; then
5050 export XUNIT_PATH=" $PWD /sponge_log.xml"
5151 export XUNIT_TMP_PATH=" $( mktemp) "
5252
53+ # We use `python3.8` because it is the version pip3 installs to.
54+ export PYTHON_CMD=" python3"
55+
5356 if [[ -f " $XUNIT_PATH " ]]; then
5457 echo " === Injecting region tags into XUnit output ==="
5558 echo " Processing XUnit output file: $XUNIT_PATH (saving output to $XUNIT_TMP_PATH )"
5659
57- # We use `python3` because it will work even if we remove old
58- # python versions from the docker image.
59- echo " Calling python3 ${PARSER_PATH} inject-snippet-mapping --output_file ${XUNIT_TMP_PATH} ${PWD} "
60+ TARGET_DIR=$PWD
61+
62+ # First, we generate a Python-specific "polyglot_snippet_data.json" file
63+ # (cd'ing into script's working dir is necessary for imports to work)
64+ echo " Calling $PYTHON_CMD ${PYTHON_PARSER_PATH} ${TARGET_DIR} "
65+ pushd $( dirname $PYTHON_PARSER_PATH )
66+ $PYTHON_CMD " $PYTHON_PARSER_PATH " " $TARGET_DIR "
67+ popd
68+
69+ # Then, we pass the "polyglot_snippet_data.json" file and the XUnit output
70+ # to the "polyglot" parser.
71+ # This outputs the XUnit input with the snippet-test map added
72+ # Again, we use `python3` for pip3 support.
73+ echo " Calling: cat $XUNIT_PATH | $PYTHON_CMD ${POLYGLOT_PARSER_PATH} inject-snippet-mapping --output_file ${XUNIT_TMP_PATH} ${TARGET_DIR} "
74+ pushd $( dirname $POLYGLOT_PARSER_PATH )
6075 cat " $XUNIT_PATH " | \
61- python3 " $PARSER_PATH " inject-snippet-mapping -- output_file " $XUNIT_TMP_PATH " " $PWD "
76+ $PYTHON_CMD " $POLYGLOT_PARSER_PATH " -- output_file " $XUNIT_TMP_PATH " inject-snippet-mapping " $TARGET_DIR "
6277 if [[ $? -eq 0 ]] && [[ -s " $XUNIT_PATH " ]]; then
6378 mv $XUNIT_TMP_PATH $XUNIT_PATH
6479 else
6580 echo " Region tag injection FAILED; XUnit file not modified."
6681 fi
82+ popd
6783 else
6884 echo " No XUnit output file found!"
6985 fi
0 commit comments