|
@@ -2,6 +2,8 @@ import unittest
|
|
|
|
|
|
from utils import *
|
|
|
import sys
|
|
|
+import os
|
|
|
+import shutil
|
|
|
|
|
|
sys.path.append("wrappers")
|
|
|
from modelverse import *
|
|
@@ -62,17 +64,25 @@ class TestPowerWindow(unittest.TestCase):
|
|
|
transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
|
|
|
transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
|
|
|
|
|
|
- global called
|
|
|
- called = 0
|
|
|
nr_of_operations = 6
|
|
|
|
|
|
+ try:
|
|
|
+ shutil.rmtree(".TEST_POWER_WINDOW")
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ os.makedirs(".TEST_POWER_WINDOW")
|
|
|
+
|
|
|
def get_function(filename):
|
|
|
def func(model):
|
|
|
- global called
|
|
|
+ import uuid
|
|
|
+ import os
|
|
|
+ called = len(os.listdir(".TEST_POWER_WINDOW/"))
|
|
|
if called > nr_of_operations:
|
|
|
raise Exception("Seemingly called some operation twice!")
|
|
|
else:
|
|
|
- called += 1
|
|
|
+ f = open(".TEST_POWER_WINDOW/%s" % str(uuid.uuid4()), 'w')
|
|
|
+ f.write(filename)
|
|
|
+ f.close()
|
|
|
model_overwrite(model, open(filename, "r").read())
|
|
|
return func
|
|
|
|
|
@@ -98,6 +108,8 @@ class TestPowerWindow(unittest.TestCase):
|
|
|
import traceback
|
|
|
print(traceback.format_exc())
|
|
|
|
|
|
+ called = len(os.listdir(".TEST_POWER_WINDOW/"))
|
|
|
+ shutil.rmtree(".TEST_POWER_WINDOW")
|
|
|
if called != 6:
|
|
|
print(called)
|
|
|
raise Exception("Not executed sufficiently:" + str(called))
|
|
@@ -153,21 +165,28 @@ class TestPowerWindow(unittest.TestCase):
|
|
|
#transformation_add_AL({"Encapsulated_PetriNet": "Encapsulated_PetriNet"}, {}, "epn_print", open("models/epn_print.alc").read())
|
|
|
#transformation_add_AL({"PetriNet": "PetriNet"}, {}, "pn_print", open("models/pn_print.alc").read())
|
|
|
|
|
|
- global called
|
|
|
- called = 0
|
|
|
+ try:
|
|
|
+ shutil.rmtree(".TEST_POWER_WINDOW")
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ os.makedirs(".TEST_POWER_WINDOW")
|
|
|
+
|
|
|
executed = set([])
|
|
|
|
|
|
def get_function(filename, fixed=None):
|
|
|
def func(model):
|
|
|
- global called
|
|
|
- if called > len(callbacks) * 2:
|
|
|
+ import uuid
|
|
|
+ import os
|
|
|
+ nr_operations = 11
|
|
|
+ called = len(os.listdir(".TEST_POWER_WINDOW/"))
|
|
|
+ if (len(os.listdir(".TEST_POWER_WINDOW")) > nr_operations):
|
|
|
raise Exception("Seemingly called some operation twice!")
|
|
|
- called += 1
|
|
|
- if filename not in executed or fixed is None:
|
|
|
- executed.add(filename)
|
|
|
+ elif (len(glob.glob(".TEST_POWER_WINDOW/%s_*" % str(filename))) == 0) or fixed is None:
|
|
|
model_overwrite(model, open(filename, "r").read())
|
|
|
else:
|
|
|
model_overwrite(model, open(fixed, "r").read())
|
|
|
+
|
|
|
+ open(".TEST_POWER_WINDOW/%s_%s" % str(filename, uuid.uuid4()), 'w').close()
|
|
|
return func
|
|
|
|
|
|
cb_req = get_function("models/requirements_model.mvc")
|
|
@@ -198,6 +217,9 @@ class TestPowerWindow(unittest.TestCase):
|
|
|
|
|
|
thrd.join()
|
|
|
|
|
|
+ called = len(os.listdir(".TEST_POWER_WINDOW"))
|
|
|
+ shutil.rmtree(".TEST_POWER_WINDOW")
|
|
|
+
|
|
|
if called != 11:
|
|
|
print(called)
|
|
|
raise Exception("Not executed sufficiently:" + str(called))
|