From: Eric Fayolle Date: Wed, 25 May 2022 15:47:38 +0000 (+0200) Subject: Exemple bug pyxb hors eficas avec deux écritures .xsd équivalents X-Git-Tag: merge_uncertainty_odysee_1210~87 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ed84d5031df4d8171718ebbb766e959c2bbe78e;p=tools%2Feficas.git Exemple bug pyxb hors eficas avec deux écritures .xsd équivalents --- diff --git a/TestPyxbBugSimplified/GNUmakefile b/TestPyxbBugSimplified/GNUmakefile new file mode 100644 index 00000000..0e3de0f1 --- /dev/null +++ b/TestPyxbBugSimplified/GNUmakefile @@ -0,0 +1,147 @@ +.SUFFIXES: .xsd .py _driver.py _test_driver_0.comm _test_driver_1.comm _test_driver_0.xml _test_driver_1.xml _test_driver_0.py _test_driver_1.py .comm .xml +#TODO : Supprimer les suffixes inutiles depuis l'utilisation des des règles pattern au lieu des règles suffixes +#TODO : Ajouter la dépendance entre le make .xml et la présence du driver +.PHONY: xsdAll driverAll +SHELL=bash + +ifdef EFICAS4VIMMP_ROOT +srcdir?=${EFICAS4VIMMP_ROOT} +else +srcdir?=.. +endif + +confdir?=$(srcdir)/config +tooldir=$(srcdir)/Tools + +# Règle en tête de Makefile +all: driverAll + +include $(confdir)/GNUmakefile.env + +#PYXB ?=pyxbgen +#PYXB ?=pyxbgen-py3 + +ifndef PYXB + ifeq (, $(shell which pyxbgen)) + ifeq (, $(shell which pyxbgen-py3)) + $(error "No pyxbgen $(PATH), consider installing pyxb") + else + PYXB =pyxbgen-py3 + endif + else + PYXB =pyxbgen + endif +endif + +################# REGLES DE CONSTRUCTION ######################## + +#Dépendances entre catalogues : +define cata_dependencies = +# Exemple: cata_gromacs$1 : cata_Vimmp$1 +endef + +#Définition des dépendances pour le modèle .py +$(eval $(call cata_dependencies,.py)) +#Définition des dépendances pour le modèle .xsd +$(eval $(call cata_dependencies,.xsd)) + +# $(subst .py,.xsd,cata_dependencies) + +cata_files= \ +cata_ko.py cata_ok.py + +cata_basename=$(cata_files:%.py=%) +xsd_files = $(cata_files:%.py=%.xsd) +driver_files= $(cata_files:%.py=%_driver.py) + +xsdAll: $(xsd_files) +driverAll: exec.sh environ.sh qtEficas.sh $(driver_files) +# qtEficasSlm.sh + + +# Exemple PyxB : $(PYXB) -m $(basename $@) -u $< --location-prefix-rewrite http://chercheurs.edf.com/logiciels/vimmp= --write-for-customization \ +# L'utilisation de $? ne fonctionne pas si l'on ne modifie qu'un seul catalogue car il liste uniquement les fichiers modifiés et pyxb détecte +# que l'autre fichier en dépend et qu'il n'a pas été regénéré en même temps: $^ +.py.xsd: + $(tooldir)/generateXSD.py -c $(abspath $<) + +.xsd_driver.py: + $(PYXB) -m $(basename $@) -u $^ --write-for-customization + xmllint --path $(confdir) --schema XMLSchema11_local.xsd --noout $^ + +#Les Tools eficas ont besoins d'un chemin absolu +#ATTENTION : La .sufix rule n'autorise pas les dépendances après le : (sinon la ligne entière est un nom de fichier bizzare) +#_test_driver_$1.comm_test_driver_$1.xml: +# il faut les définir à part +# TODO : +#.SECONDEXPANSION: +#%_test_driver_$1.xml : %_test_driver_$1.comm $$(realpath $$(*).py) $$(*)_driver.py + +define test_xml_rule = +%_test_driver_$1.xml : %_test_driver_$1.comm $$(realpath $$(*).py) + @echo -e "\n\n------ Generate xml test file $$(@) ------\n" + @[[ -f $$(*).py ]] || (echo "Le fichier catalogue $$(*).py est introuvable" && false) + @[[ -f $$(*)_driver.py ]] || (echo "Le fichier driver $$(*)_driver.py est introuvable" && false) + $(tooldir)/generateXML.py -c $$(abspath $$(*).py) $$< +endef + + +#ATTENTION : La .sufix rule n'autorise pas les dépendances après le : (sinon la ligne entière est un nom de fichier bizzare) +#_test_driver_$1.comm_test_driver_$1.py: +# il faut les définir à part +define test_driver_rule = +%_test_driver_$1.py : %_test_driver_$1.xml $(confdir)/test_driver_subst.py + @echo -e "\n\n------ Generate xml test driver $$(@) ------\n" + sed -e "s,@module@,$$(*)_driver,g" -e "s,@file@,$$(<),g" $$(confdir)/test_driver_subst.py > $$(@) && \ + chmod +x $$(<:%.xml=%.py); +endef + +define test_comm_rule = +%_test_driver_$1_modified.comm : %_test_driver_$1.xml + @echo -e "\n\n------ Generate modified.comm file $$(@) ------\n" + @[[ -f $$(*).py ]] || (echo "Le fichier catalogue $$(*).py est introuvable" && false) + @[[ -f $$(*)_driver.py ]] || (echo "Le fichier driver $$(*)_driver.py est introuvable" && false) + $(tooldir)/generateComm.py -x -c $$(abspath $$(*).py) -o $$(@) $$< +endef + +#Définition des règles de construction pour les tests +#$(eval $(call test_driver_rule,0)) +#$(eval $(call test_driver_rule,1)) +$(foreach it,0 1 2 3 4 5 6 7 8 9, $(eval $(call test_xml_rule,$(it))) ) +$(foreach it,0 1 2 3 4 5 6 7 8 9, $(eval $(call test_driver_rule,$(it))) ) +$(foreach it,0 1 2 3 4 5 6 7 8 9, $(eval $(call test_comm_rule,$(it))) ) + +#test_driver_xml:= $(patsubst %.comm,%.xml,$(wildcard *_test_driver_?.comm)) +#test_driver_py:= $(patsubst %.comm,%.py,$(wildcard *_test_driver_?.comm)) + +new_test_driver_xml:= $(foreach it,$(cata_basename), $(patsubst %.comm,%.xml,$(wildcard $(it)_test_driver_?.comm)) ) +new_test_driver_py:= $(foreach it,$(cata_basename), $(patsubst %.comm,%.py,$(wildcard $(it)_test_driver_?.comm)) ) +new_test_driver_comm:= $(foreach it,$(cata_basename), $(patsubst %.comm,%_modified.comm,$(wildcard $(it)_test_driver_?.comm)) ) + +#$(info $(new_test_driver_xml) "----" $(cata_basename) ) +#$(info $(new_test_driver_py) "----" $(cata_basename) ) + +# xml: +# @echo "Reminder: a .comm file is needed for this step" +# ../tools/generateXML.py -c cata_1.py cata_1_test_1.comm + +check test: testAll + +################# REGLES DE TESTS ######################## + +testAll: exec.sh driverAll $(new_test_driver_py) $(new_test_driver_xml) $(new_test_driver_comm) + @for i in $(new_test_driver_py) ; do echo -e "\n\n------ Launching $$i ------" && ./exec.sh python3 $$i ; done +# for i in `ls *_test_driver*.py` ; do echo -e "\n\n------ Launching $$i ------" && ./exec.sh python $$i || break ; done + +################# REGLES DE NETTOYAGE ######################## + +clean: + rm -f *.pyc *~ qtEficas.sh exec.sh environ.sh + rm -rf raw binding.py __pycache__ + rm -f $(driver_files) *test_driver_?.py *test_driver_?_modified.comm +#rm -f $(xsd_files) $(driver_files) *test_driver_?.py *test_driver_?.xml *test_driver_?_modified.comm + +cleantest: + rm -f *test_driver_?.py *test_driver_?_modified.comm +# rm -f *test_driver_?.py *test_driver_?.xml *test_driver_?_modified.comm + diff --git a/TestPyxbBugSimplified/built/cata_ko_test_driver_1.py b/TestPyxbBugSimplified/built/cata_ko_test_driver_1.py new file mode 100755 index 00000000..be464b76 --- /dev/null +++ b/TestPyxbBugSimplified/built/cata_ko_test_driver_1.py @@ -0,0 +1,12 @@ +#! /usr/bin/env python3 +# -*- coding:utf-8 -*- +import sys + +#print(sys.argv[:]) + +import cata_ko_driver as mdm +import pyxb + +o1 = mdm.CreateFromDocument(open('cata_ko_test_driver_1.xml').read()) +print(o1.toDOM().toprettyxml()) + diff --git a/TestPyxbBugSimplified/built/cata_ok_test_driver_1.py b/TestPyxbBugSimplified/built/cata_ok_test_driver_1.py new file mode 100755 index 00000000..60f6ccef --- /dev/null +++ b/TestPyxbBugSimplified/built/cata_ok_test_driver_1.py @@ -0,0 +1,12 @@ +#! /usr/bin/env python3 +# -*- coding:utf-8 -*- +import sys + +#print(sys.argv[:]) + +import cata_ok_driver as mdm +import pyxb + +o1 = mdm.CreateFromDocument(open('cata_ok_test_driver_1.xml').read()) +print(o1.toDOM().toprettyxml()) + diff --git a/TestPyxbBugSimplified/cata.xsd b/TestPyxbBugSimplified/cata.xsd new file mode 100644 index 00000000..4fe1765a --- /dev/null +++ b/TestPyxbBugSimplified/cata.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Possible Conditions : + loi == 1 + loi == 2 + + + + + + + + + + + diff --git a/TestPyxbBugSimplified/cata_ko.xsd b/TestPyxbBugSimplified/cata_ko.xsd new file mode 120000 index 00000000..52f5fba9 --- /dev/null +++ b/TestPyxbBugSimplified/cata_ko.xsd @@ -0,0 +1 @@ +ko/cata.xsd \ No newline at end of file diff --git a/TestPyxbBugSimplified/cata_ko_test_driver_1.xml b/TestPyxbBugSimplified/cata_ko_test_driver_1.xml new file mode 120000 index 00000000..b77f1a08 --- /dev/null +++ b/TestPyxbBugSimplified/cata_ko_test_driver_1.xml @@ -0,0 +1 @@ +cata_test_driver_1.xml \ No newline at end of file diff --git a/TestPyxbBugSimplified/cata_ok.xsd b/TestPyxbBugSimplified/cata_ok.xsd new file mode 120000 index 00000000..e9a1d8ed --- /dev/null +++ b/TestPyxbBugSimplified/cata_ok.xsd @@ -0,0 +1 @@ +ok/cata.xsd \ No newline at end of file diff --git a/TestPyxbBugSimplified/cata_ok_test_driver_1.xml b/TestPyxbBugSimplified/cata_ok_test_driver_1.xml new file mode 120000 index 00000000..b77f1a08 --- /dev/null +++ b/TestPyxbBugSimplified/cata_ok_test_driver_1.xml @@ -0,0 +1 @@ +cata_test_driver_1.xml \ No newline at end of file diff --git a/TestPyxbBugSimplified/cata_test_driver_1.xml b/TestPyxbBugSimplified/cata_test_driver_1.xml new file mode 100644 index 00000000..92caffa9 --- /dev/null +++ b/TestPyxbBugSimplified/cata_test_driver_1.xml @@ -0,0 +1,8 @@ + + + + 1 + 1 + 1.0 + + diff --git a/TestPyxbBugSimplified/cata_test_driver_1.xml.ref b/TestPyxbBugSimplified/cata_test_driver_1.xml.ref new file mode 100644 index 00000000..92caffa9 --- /dev/null +++ b/TestPyxbBugSimplified/cata_test_driver_1.xml.ref @@ -0,0 +1,8 @@ + + + + 1 + 1 + 1.0 + + diff --git a/TestPyxbBugSimplified/cata_test_driver_1_modified.xml b/TestPyxbBugSimplified/cata_test_driver_1_modified.xml new file mode 100644 index 00000000..5c2ebcaf --- /dev/null +++ b/TestPyxbBugSimplified/cata_test_driver_1_modified.xml @@ -0,0 +1,7 @@ + + + + 1 + 1.0 + + diff --git a/TestPyxbBugSimplified/commands_sans_makefile_a_tester_en_py35_ou_py+36 b/TestPyxbBugSimplified/commands_sans_makefile_a_tester_en_py35_ou_py+36 new file mode 100755 index 00000000..225ea8f7 --- /dev/null +++ b/TestPyxbBugSimplified/commands_sans_makefile_a_tester_en_py35_ou_py+36 @@ -0,0 +1,6 @@ +pyxbgen-py3 -m cata_ok_driver -u cata_ok.xsd --write-for-customization +pyxbgen-py3 -m cata_ko_driver -u cata_ko.xsd --write-for-customization +cp built/cata_ok_test_driver_1.py cata_ok_test_driver_1.py +cp built/cata_ko_test_driver_1.py cata_ko_test_driver_1.py +./cata_ok_test_driver_1.py +./cata_ko_test_driver_1.py diff --git a/TestPyxbBugSimplified/commands_sous_repertoire_eficas_avec_makefile_a_tester_en_py35_ou_py+36 b/TestPyxbBugSimplified/commands_sous_repertoire_eficas_avec_makefile_a_tester_en_py35_ou_py+36 new file mode 100755 index 00000000..f0e9c0db --- /dev/null +++ b/TestPyxbBugSimplified/commands_sous_repertoire_eficas_avec_makefile_a_tester_en_py35_ou_py+36 @@ -0,0 +1,6 @@ +make cata_ok_driver.py +make cata_ko_driver.py +make cata_ok_test_driver_1.py +make cata_ko_test_driver_1.py +./cata_ok_test_driver_1.py +./cata_ko_test_driver_1.py diff --git a/TestPyxbBugSimplified/ko/cata.xsd b/TestPyxbBugSimplified/ko/cata.xsd new file mode 100644 index 00000000..2a053d94 --- /dev/null +++ b/TestPyxbBugSimplified/ko/cata.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Possible Conditions : + loi == 1 + loi == 2 + + + + + + + + + + + diff --git a/TestPyxbBugSimplified/ok/cata.xsd b/TestPyxbBugSimplified/ok/cata.xsd new file mode 100644 index 00000000..4fe1765a --- /dev/null +++ b/TestPyxbBugSimplified/ok/cata.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Possible Conditions : + loi == 1 + loi == 2 + + + + + + + + + + +