@@ -11,25 +11,55 @@ pip list
1111
1212export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/3x/coverage.3x_pt
1313inc_path=$( python -c ' import neural_compressor; print(neural_compressor.__path__[0])' )
14- cd /neural-compressor/test || exit 1
15- find ./3x/torch/* -name " test*.py" | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append ,g' | sed ' s/$/ --verbose/' > run.sh
16- find ./3x/common/* -name " test*.py" | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append ,g' | sed ' s/$/ --verbose/' >> run.sh
14+ cd /neural-compressor/test/3x || exit 1
15+ grep -lrv " import pytest" --include=" test*.py" ./torch | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append ,g' | sed ' s/$/ --verbose/' > run_unittest.sh
16+ grep -lrv " import pytest" --include=" test*.py" ./common | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append ,g' | sed ' s/$/ --verbose/' >> run_unittest.sh
17+ grep -lr " import pytest" --include=" test*.py" ./torch | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append -m pytest --disable-warnings -v ,g' > run_pytest.sh
18+ grep -lr " import pytest" --include=" test*.py" ./common | sed ' s,\.\/,coverage run --source=' " ${inc_path} " ' --append -m pytest --disable-warnings -v ,g' >> run_pytest.sh
1719
1820LOG_DIR=/neural-compressor/log_dir
1921mkdir -p ${LOG_DIR}
2022ut_log_name=${LOG_DIR} /ut_3x_pt.log
2123
22- echo " cat run.sh..."
23- sort run.sh -o run.sh
24- cat run.sh | tee ${ut_log_name}
25- echo " ------UT start-------"
26- bash -x run.sh 2>&1 | tee -a ${ut_log_name}
24+ # unittest and pytest has some incompatible issue, so separate the test.
25+ echo " cat run_unittest.sh..."
26+ sort run_unittest.sh -o run_unittest.sh
27+ cat run_unittest.sh | tee ${ut_log_name}
28+ echo " ------unittest start-------"
29+ bash -x run_unittest.sh 2>&1 | tee -a ${ut_log_name}
30+ echo " ------unittest end -------"
31+
32+ if [ -s run_pytest.sh ]; then
33+ echo " cat run_pytest.sh..."
34+ sort run_pytest.sh -o run_pytest.sh
35+ cat run_pytest.sh | tee -a ${ut_log_name}
36+ echo " ------pytest start-------"
37+ bash -x run_pytest.sh 2>&1 | tee -a ${ut_log_name}
38+ echo " ------pytest end -------"
39+ fi
40+
2741cp .coverage ${LOG_DIR} /.coverage
2842
29- echo " ------UT end -------"
43+ ut_status=" passed"
44+ # check unittest issue
45+ if [ $( grep -c " FAILED" ${ut_log_name} ) != 0 ] || [ $( grep -c " core dumped" ${ut_log_name} ) != 0 ] \
46+ || [ $( grep -c " ModuleNotFoundError:" ${ut_log_name} ) != 0 ] || [ $( grep -c " ImportError:" ${ut_log_name} ) != 0 ] || [ $( grep -c " OK" ${ut_log_name} ) == 0 ]; then
47+ echo " Find errors in unittest case, please check the output..."
48+ echo " Please search for 'FAILED' or 'core dumped' or 'ModuleNotFoundError:' or 'ImportError:'"
49+ ut_status=" failed"
50+ fi
3051
31- if [ $( grep -c " FAILED" ${ut_log_name} ) != 0 ] || [ $( grep -c " core dumped" ${ut_log_name} ) != 0 ] || [ $( grep -c " ModuleNotFoundError:" ${ut_log_name} ) != 0 ] || [ $( grep -c " OK" ${ut_log_name} ) == 0 ]; then
32- echo " Find errors in UT test, please check the output..."
52+ # check pytest issue
53+ if [ -s run_pytest.sh ]; then
54+ if [ $( grep -c ' == FAILURES ==' ${ut_log_name} ) != 0 ] || [ $( grep -c ' == ERRORS ==' ${ut_log_name} ) != 0 ] || [ $( grep -c ' passed,' ${ut_log_name} ) == 0 ]; then
55+ echo " Find errors in pytest case, please check the output..."
56+ echo " Please search for '== FAILURES ==' or '== ERRORS =='"
57+ ut_status=" failed"
58+ fi
59+ fi
60+
61+ if [ " $ut_status " = " failed" ]; then
3362 exit 1
3463fi
64+
3565echo " UT finished successfully! "
0 commit comments