MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit e87913fa authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib][tests] Hardening expression compiler tests; always check reporter state

Conflicts:
	library/cadbiom/models/biosignal/translators/TestExprCompiler.py
parent bb489d45
......@@ -61,17 +61,16 @@ class Reporter(object):
Simple reporter
"""
def __init__(self):
self.mem = ">>>>>>>>"
self.message = ""
self.error = False
def display(self, mess):
def display(self, message):
"""
Just register messages
"""
self.error = True
self.mem = self.mem + "\n" + mess
LOGGER.error("TestExprCompiler: %s", self.mem)
self.message += "\n" + message
LOGGER.error("TestExprCompiler: %s", message)
class TestExpressionAnalyzer(unittest.TestCase):
......@@ -111,7 +110,6 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.st2 = SigIdentExpr('S2')
self.st3 = SigIdentExpr('S3')
self.err_rep = Reporter()
self.tab = {}
self.tab['X1'] = "emit", 1
self.tab['X2'] = "input", 1
......@@ -182,6 +180,8 @@ class TestExpressionAnalyzer(unittest.TestCase):
res = exp141.test_equal(exp14)
self.assert_(not res, "Error in Expression equality Test10")
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_default(self):
"""
......@@ -203,6 +203,9 @@ class TestExpressionAnalyzer(unittest.TestCase):
res = exp101.test_equal(exp_obj.exp)
self.assert_(res, "Error in Expression analyzer for default")
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_when(self):
"""
when left associativity
......@@ -221,6 +224,9 @@ class TestExpressionAnalyzer(unittest.TestCase):
res = exp111.test_equal(exp_obj.exp)
self.assert_(res, "Error in Expression analyzer for when")
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_default_when(self):
"""
priority of when over default
......@@ -240,6 +246,9 @@ class TestExpressionAnalyzer(unittest.TestCase):
mess = "Error in Expression analyzer for X1 default X3 when X4"
self.assert_(res, mess)
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_void(self):
"""
void string : default value True
......@@ -264,6 +273,8 @@ class TestExpressionAnalyzer(unittest.TestCase):
# res = exp112.test_equal(exp_obj.exp)
# mess = "Error in Expression analyzer for (X1 and X3 and X4)"
# self.assert_(res, mess)
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_when_or(self):
"""
......@@ -283,6 +294,9 @@ class TestExpressionAnalyzer(unittest.TestCase):
res = exp111.test_equal(exp_obj.exp)
self.assert_(res, "Error in Expression analyzer for when_or")
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_type_error1(self):
"""
boolean expr on states in default
......@@ -309,9 +323,9 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.assert_(True, "Compiler error for when")
# False if no error (display() method is never called)
res = self.err_rep.error
#print(self.err_rep.mem)
self.assert_(not res, "Type checking error in test_type_error1")
# X3 has a type 'emit' but state_only is not activated
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
def test_type_error2(self):
"""
......@@ -340,9 +354,7 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.assert_(True, "Compiler error for when")
# False if no error (display() method is never called)
# Here, res is True because X3 has a type 'emit' not 'state' or 'input'
# Here, res is True because X3 has a type 'emit': not 'state' or 'input'
# These types are tested when state_only is True
res = self.err_rep.error
#print(self.err_rep.mem)
self.assert_(res, "Type checking error in test_type_error2")
print(self.err_rep.message)
self.assert_(self.err_rep.error, "reporter HAS NOT captured an error")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment