[FIX] script test: disable test and support multiple odoo logic

This commit is contained in:
Mathieu Benoit 2025-04-23 04:38:45 -04:00
parent b86767c0f8
commit a0c86c1866
7 changed files with 90 additions and 34 deletions

View file

@ -73,6 +73,8 @@ On_IPurple='\033[0;105m' # Purple
On_ICyan='\033[0;106m' # Cyan
On_IWhite='\033[0;107m' # White
ODOO_VERSION=$(cat .odoo-version)
check_git() {
REP=$1
cd "${REP}" || exit
@ -110,5 +112,5 @@ if [ $# -gt 0 ]; then
fi
else
# check_git "./addons/TechnoLibre_odoo-code-generator"
check_git "./addons/TechnoLibre_odoo-code-generator-template"
check_git "./addons.odoo${ODOO_VERSION}/TechnoLibre_odoo-code-generator-template"
fi

View file

@ -15,6 +15,7 @@ fi
INIT_DATETIME=$(date +%s)
if [[ $# -eq 5 ]]; then
echo ./script/addons/install_addons_dev.sh "$1" "$2" "$5"
./script/addons/install_addons_dev.sh "$1" "$2" "$5"
retVal=$?
if [[ $retVal -ne 0 ]]; then
@ -22,6 +23,7 @@ if [[ $# -eq 5 ]]; then
exit 1
fi
else
echo ./script/addons/install_addons_dev.sh "$1" "$2"
./script/addons/install_addons_dev.sh "$1" "$2"
retVal=$?
if [[ $retVal -ne 0 ]]; then
@ -31,6 +33,7 @@ else
fi
# Check if the code was updated
echo ./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}"
./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}"
retVal=$?
if [[ $retVal -ne 0 ]]; then
@ -39,6 +42,7 @@ if [[ $retVal -ne 0 ]]; then
fi
# TODO check output when got warning
echo ./script/git/repo_revert_git_diff_date_from_code_generator.py --repo "$3"
./script/git/repo_revert_git_diff_date_from_code_generator.py --repo "$3"
# Remove pot and po diff
cd "$3" || exit 1
@ -63,6 +67,7 @@ for element in "${elements[@]}"; do
done
echo "TEST ${2}"
echo ./script/code_generator/check_git_change_code_generator.sh "$3"
./script/code_generator/check_git_change_code_generator.sh "$3"
retVal=$?
if [[ $retVal -ne 0 ]]; then

View file

@ -14,9 +14,6 @@ import uuid
from git import Repo
from git.exc import InvalidGitRepositoryError, NoSuchPathError
CODE_GENERATOR_DIRECTORY = "./addons/TechnoLibre_odoo-code-generator-template/"
CODE_GENERATOR_DEMO_NAME = "code_generator_demo"
KEY_REPLACE_CODE_GENERATOR_DEMO = 'MODULE_NAME = "%s"'
logging.basicConfig(
format=(
@ -28,6 +25,19 @@ logging.basicConfig(
)
_logger = logging.getLogger(__name__)
filename_odoo_version = ".odoo-version"
if not os.path.isfile(filename_odoo_version):
_logger.error(f"Missing file {filename_odoo_version}")
sys.exit(1)
with open(".odoo-version", "r") as f:
odoo_version = f.readline()
CODE_GENERATOR_DIRECTORY = (
f"./addons.odoo{odoo_version}/TechnoLibre_odoo-code-generator-template/"
)
CODE_GENERATOR_DEMO_NAME = "code_generator_demo"
KEY_REPLACE_CODE_GENERATOR_DEMO = 'MODULE_NAME = "%s"'
class Struct:
def __init__(self, **entries):
@ -132,6 +142,11 @@ class ProjectManagement:
self.has_config_update = False
self.odoo_config = odoo_config
# Replace addons/ by addons.odoo12.0/
module_directory = module_directory.replace(
"addons/", f"addons.odoo{odoo_version}/"
)
self.module_directory = module_directory
if not os.path.exists(self.module_directory):
self.msg_error = (

View file

@ -22,6 +22,14 @@ logging.basicConfig(
)
_logger = logging.getLogger(__name__)
FILENAME_ODOO_VERSION = ".odoo-version"
if not os.path.isfile(FILENAME_ODOO_VERSION):
_logger.error(f"Missing file {FILENAME_ODOO_VERSION}")
sys.exit(1)
with open(".odoo-version", "r") as f:
ODOO_VERSION = f.readline()
def get_config():
"""Parse command line arguments, extracting the config file name,
@ -39,7 +47,7 @@ def get_config():
)
parser.add_argument(
"--repo",
default="./addons/TechnoLibre_odoo-code-generator-template;./addons/OCA_server-tools",
default=f"./addons.odoo{ODOO_VERSION}/TechnoLibre_odoo-code-generator-template;./addons.odoo{ODOO_VERSION}/OCA_server-tools",
)
args = parser.parse_args()
return args

View file

@ -1,13 +1,14 @@
#!/usr/bin/env bash
# Open a new gnome-terminal with different path on new tab
ODOO_VERSION=$(cat .odoo-version)
working_path=$(readlink -f .)
paths=(
"${working_path}/"
"${working_path}/"
"${working_path}/addons/ERPLibre_erplibre_addons"
"${working_path}/addons/TechnoLibre_odoo-code-generator"
"${working_path}/addons/TechnoLibre_odoo-code-generator-template"
# "${working_path}/addons/OCA_server-tools"
"${working_path}/addons.odoo${ODOO_VERSION}/ERPLibre_erplibre_addons"
"${working_path}/addons.odoo${ODOO_VERSION}/TechnoLibre_odoo-code-generator"
"${working_path}/addons.odoo${ODOO_VERSION}/TechnoLibre_odoo-code-generator-template"
# "${working_path}/addons.odoo${ODOO_VERSION}/OCA_server-tools"
)

View file

@ -10,28 +10,29 @@
{
"run_test_exec": true,
"test_name": "code_generator_theme_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "theme_website_demo_code_generator",
"tested_module": "code_generator_demo_theme_website"
},
{
"run_test_exec": true,
"disable": true,
"test_name": "code_generator_demo_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "code_generator_demo",
"tested_module": "code_generator_demo"
},
{
"run_test_exec": true,
"test_name": "code_generator_data_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_helpdesk_data",
"tested_module": "code_generator_demo_export_helpdesk"
},
{
"run_test_exec": true,
"test_name": "code_generator_data_part_2_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_website_data",
"tested_module": "code_generator_demo_export_website",
"note": "Merge to code_generator_data_test when fix double export data."
@ -39,14 +40,14 @@
{
"run_test_exec": true,
"test_name": "code_generator_inherit_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_internal_inherit",
"tested_module": "code_generator_demo_internal_inherit"
},
{
"run_test_exec": true,
"test_name": "code_generator_template_demo_internal",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "code_generator_demo_internal",
"tested_module": "code_generator_template_demo_internal",
"search_class_module": "demo_internal",
@ -55,7 +56,7 @@
{
"run_test_exec": true,
"test_name": "code_generator_template_demo_portal",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "code_generator_demo_portal",
"tested_module": "code_generator_template_demo_portal",
"search_class_module": "demo_portal",
@ -65,7 +66,7 @@
"run_test_exec": true,
"disable": true,
"test_name": "mariadb_test_template",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "code_generator_demo_mariadb_sql_example_1",
"tested_module": "code_generator_template_demo_mariadb_sql_example_1",
"search_class_module": "demo_mariadb_sql_example_1",
@ -75,7 +76,7 @@
"run_test_exec": true,
"disable": true,
"test_name": "mariadb_test_migrator",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_mariadb_sql_example_1",
"tested_module": "code_generator_migrator_demo_mariadb_sql_example_1",
"script_after_init_check": "./script/database/restore_mariadb_sql_example_1.sh",
@ -85,7 +86,7 @@
"run_test_exec": true,
"disable": true,
"test_name": "mariadb_test_code_generator",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_mariadb_sql_example_1",
"tested_module": "code_generator_demo_mariadb_sql_example_1",
"init_module_name": "code_generator_portal"
@ -93,7 +94,7 @@
{
"run_test_exec": true,
"test_name": "code_generator_template_demo_internal_inherit",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "code_generator_demo_internal_inherit",
"tested_module": "code_generator_template_demo_internal_inherit",
"search_class_module": "demo_internal_inherit",
@ -101,34 +102,37 @@
},
{
"run_test_exec": true,
"disable": true,
"test_name": "code_generator_template_demo_sysadmin_cron",
"path_module_check": "./addons/OCA_server-tools/auto_backup",
"path_module_check": "./addons.odoo12.0/OCA_server-tools",
"generated_module": "code_generator_auto_backup",
"generated_path": "./addons/OCA_server-tools/",
"generated_path": "./addons.odoo12.0/OCA_server-tools/",
"tested_module": "code_generator_template_demo_sysadmin_cron",
"search_class_module": "auto_backup",
"init_module_name": "auto_backup",
"install_path": "./addons/TechnoLibre_odoo-code-generator-template"
"install_path": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template"
},
{
"run_test_exec": true,
"disable": true,
"test_name": "code_generator_export_website_attachments_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_website_attachments_data",
"tested_module": "code_generator_demo_export_website_attachments",
"restore_db_image_name": "test_website_attachments"
},
{
"run_test_exec": true,
"disable": true,
"test_name": "code_generator_demo_generic_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_internal,demo_portal",
"tested_module": "code_generator_demo_internal,code_generator_demo_portal"
},
{
"run_test_exec": true,
"test_name": "code_generator_website_snippet_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"generated_module": "demo_website_leaflet,demo_website_snippet,demo_website_multiple_snippet",
"tested_module": "code_generator_demo_website_leaflet,code_generator_demo_website_snippet,code_generator_demo_website_multiple_snippet",
"file_to_restore": "demo_portal/i18n/demo_portal.pot,demo_portal/i18n/fr_CA.po",
@ -138,13 +142,13 @@
{
"run_test_exec": true,
"test_name": "demo_test",
"path_module_check": "./addons/TechnoLibre_odoo-code-generator-template",
"path_module_check": "./addons.odoo12.0/TechnoLibre_odoo-code-generator-template",
"init_module_name": "demo_helpdesk_data,demo_internal,demo_internal_inherit,demo_mariadb_sql_example_1,demo_portal,demo_website_data,demo_website_leaflet,demo_website_snippet"
},
{
"run_test_exec": true,
"test_name": "code_generator_auto_backup_test",
"path_module_check": "./addons/OCA_server-tools/auto_backup",
"path_module_check": "./addons.odoo12.0/OCA_server-tools/auto_backup",
"generated_module": "auto_backup",
"tested_module": "code_generator_auto_backup"
}

View file

@ -30,8 +30,16 @@ from script import lib_asyncio
logging.basicConfig(level=logging.DEBUG)
_logger = logging.getLogger(__name__)
FILENAME_ODOO_VERSION = ".odoo-version"
if not os.path.isfile(FILENAME_ODOO_VERSION):
_logger.error(f"Missing file {FILENAME_ODOO_VERSION}")
sys.exit(1)
with open(".odoo-version", "r") as f:
ODOO_VERSION = f.readline()
LOG_FILE = "./.venv/make_test.log"
CONFIG_TESTCASE_JSON = "./script/test/config_testcase.json"
CONFIG_TESTCASE_JSON = f"./script/test/config_testcase.odoo{ODOO_VERSION}.json"
def get_config():
@ -136,7 +144,12 @@ def extract_result(result, test_name, lst_error, lst_warning):
if not is_ignore_warning:
lst_warning.append(log_line)
if result[1]:
lst_error.append(f"Return status error for test {test_name}")
if len(result[0].split("\n")) == 1:
lst_error.append(
f"Return status error for test {test_name} : {result[0]}"
)
else:
lst_error.append(f"Return status error for test {test_name}")
def check_result(task_list, tpl_result):
@ -422,7 +435,10 @@ async def test_exec(
# Update path to change new emplacement
s_lst_path_tested_module = (
await lib_asyncio.run_command_get_output(
"find", "./addons/", "-name", module_name
"find",
f"./addons.odoo{ODOO_VERSION}/",
"-name",
module_name,
)
)
if not s_lst_path_tested_module:
@ -437,6 +453,7 @@ async def test_exec(
s_lst_path_tested_module.strip().split("\n")
)
s_first_path = lst_path_tested_module[0]
# parent_dir = os.path.dirname(s_first_path).replace("addons/", f"addons.odoo{ODOO_VERSION}/")
parent_dir = os.path.dirname(s_first_path)
# Copy it
if copy_path != parent_dir:
@ -546,7 +563,7 @@ async def test_exec(
else:
new_hook_line = (
hook_line[: first_index + len(f_key)]
+ f'"{s_first_path}"\n'
+ f'"{s_first_path}"'
+ hook_line[index_end_string:]
)
new_hook_line = new_hook_line.replace(
@ -782,7 +799,7 @@ def check_git_change():
task_list = [
run_command(
"./script/code_generator/check_git_change_code_generator.sh",
"./addons/TechnoLibre_odoo-code-generator-template",
f"./addons.odoo{ODOO_VERSION}/TechnoLibre_odoo-code-generator-template",
test_name=(
"Init check_git_change"
" TechnoLibre_odoo-code-generator-template"
@ -790,7 +807,7 @@ def check_git_change():
),
run_command(
"./script/code_generator/check_git_change_code_generator.sh",
"./addons/OCA_server-tools",
f"./addons.odoo{ODOO_VERSION}/OCA_server-tools",
test_name="Init check_git_change OCA_server-tools",
),
]
@ -828,6 +845,10 @@ def run_all_test(config) -> bool:
for dct_test in lst_test:
if dct_test.get("disable"):
continue
# Force change addons path
# if "path_module_check" in dct_test.keys():
# # dct_test["path_module_check"] = dct_test["path_module_check"].replace("addons/", f"addons.odoo{ODOO_VERSION}/")
# dct_test["path_module_check"] = dct_test["path_module_check"]
sequence = dct_test.get("sequence", 0)
cb_coroutine = None
test_name = None