Mercurial > repos > lain > history_metadata_extractor
comparison manual_test.sh @ 0:426b0f85a311 draft
" master branch Updating"
author | lain |
---|---|
date | Tue, 19 Jul 2022 07:36:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:426b0f85a311 |
---|---|
1 #!/bin/bash | |
2 | |
3 | |
4 | |
5 ## **@AUTHOR**: Lain Pavot - lain.pavot@inrae.fr | |
6 ## **@DATE**: 22/06/2022 | |
7 | |
8 | |
9 envs_directory=$(pwd) | |
10 envs_directory=/tmp/history_metadata_extractor-envs | |
11 mkdir -p ${envs_directory} | |
12 | |
13 VENV=${envs_directory}/.manual-venv | |
14 CENV=${envs_directory}/.manual-conda | |
15 | |
16 MAMBA_SOLVER= | |
17 ## comment to deactivate mamba solver | |
18 MAMBA_SOLVER="--experimental-solver libmamba" | |
19 | |
20 ENV_NAME=history_metadata_extractor | |
21 XML_PATH=./history_metadata_extractor.xml | |
22 SCRIPT_NAME=history_metadata_extractor.py | |
23 output_name=out.html | |
24 options=" \ | |
25 -d ./test-data/datasets_attrs.txt \ | |
26 -j ./test-data/jobs_attrs.txt \ | |
27 -o ./${output_name} \ | |
28 " | |
29 expected_result=test-data/out.html | |
30 runner=python3.10 | |
31 dependencies=python=3.10.5 | |
32 miniconda_version=py37_4.12.0-Linux-x86_64 | |
33 | |
34 | |
35 | |
36 if [ ! -e "${VENV}" ];then | |
37 echo "virtualenv not created yet, creating..." | |
38 python3 -m virtualenv "${VENV}" | |
39 echo "venv created" | |
40 else | |
41 echo "virtualenv already exist: ok" | |
42 fi | |
43 . ${VENV}/bin/activate | |
44 | |
45 if [ ! -e "${CENV}" ];then | |
46 echo "conda env not created yet, creating..." | |
47 if [ ! -e ./install_conda.sh ];then | |
48 wget \ | |
49 -O install_conda.sh \ | |
50 https://repo.anaconda.com/miniconda/Miniconda3-${miniconda_version}.sh \ | |
51 ; | |
52 fi | |
53 bash ./install_conda.sh -b -p "${CENV}" | |
54 | |
55 ${CENV}/bin/conda install -y -n base conda-libmamba-solver | |
56 ${CENV}/bin/conda create \ | |
57 -y \ | |
58 --quiet \ | |
59 --override-channels \ | |
60 --channel conda-forge \ | |
61 --channel bioconda \ | |
62 --channel defaults \ | |
63 --name "${ENV_NAME}" \ | |
64 ${MAMBA_SOLVER} \ | |
65 ${dependencies} | |
66 echo "conda env created" | |
67 fi | |
68 | |
69 echo "" | |
70 echo "===== preparing =====" | |
71 | |
72 oldwd=$(pwd) | |
73 tmp=$(mktemp -d) | |
74 echo "Working in ${tmp}" | |
75 files=$(find . -maxdepth 1 -regex "./.+") | |
76 cd "${tmp}" | |
77 echo "creating links..." | |
78 echo "${files}" | xargs -I file ln -s "${oldwd}"/file file | |
79 echo "ready to work" | |
80 | |
81 echo "" | |
82 echo "===== processing =====" | |
83 | |
84 . "${CENV}/bin/activate" "${CENV}/envs/${ENV_NAME}" ; | |
85 | |
86 ${runner} ./${SCRIPT_NAME} ${options}; | |
87 | |
88 echo "" | |
89 echo "Error code: ${?}" ; | |
90 | |
91 lines=$(diff "${output_name}" "${expected_result}" 2>&1) | |
92 | |
93 echo "" | |
94 echo "===== results =====" | |
95 | |
96 if [ "${lines}" = "" ];then | |
97 echo "Result equal to expected." | |
98 else | |
99 echo "Some lines are different:" | |
100 echo "${lines}" | |
101 fi | |
102 | |
103 echo "" | |
104 echo "===== cleaning =====" | |
105 | |
106 echo "Removing ${tmp}..." | |
107 rm -rf "${tmp}" | |
108 | |
109 echo "" | |
110 echo "Done." |