Prechádzať zdrojové kódy

Poll for failures much earlier in tests

Yentl Van Tendeloo 9 rokov pred
rodič
commit
b2264e0637
2 zmenil súbory, kde vykonal 28 pridanie a 6 odobranie
  1. 7 0
      bootstrap/modelling.alc
  2. 21 6
      integration/utils.py

+ 7 - 0
bootstrap/modelling.alc

@@ -94,7 +94,9 @@ Element function find_attribute_type(model : Element, elem : String, name : Stri
 	Element mm_elem
 	Element direct_type
 
+	log("Search for type of " + elem)
 	direct_type = dict_read_node(model["type_mapping"], model["model"][elem])
+	print("Direct type: " + cast_e2s(direct_type))
 	mm_elem = find_attribute_definer(model["metamodel"], direct_type, name)
 
 	if (element_eq(mm_elem, read_root())):
@@ -114,6 +116,7 @@ Element function get_superclasses(model : Element, elem : Element):
 	i = 0
 
 	// Read out all outgoing edges
+	log(cast_e2s(elem))
 	num_edges = read_nr_out(elem)
 	while (i < num_edges):
 		edge = read_out(elem, i)
@@ -133,6 +136,8 @@ Element function find_attribute_definer(model : Element, elem : Element, name :
 		Element current
 		Element found
 
+		log("Finding for element " + cast_e2s(elem))
+
 		superclasses = get_superclasses(model, elem)
 		while (list_len(superclasses) > 0):
 			current = set_pop(superclasses)
@@ -150,7 +155,9 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 	String attr_type
 	String attr_name
 
+	log("Instantiating attribute " + attribute_name)
 	attr_type = find_attribute_type(model, element, attribute_name)
+	log("DONE")
 	attr_name = model_add_value(model, "", value)
 	retype(model, attr_name, getName(model["metamodel"], read_edge_dst(model["metamodel"]["model"][attr_type])))
 	instantiate_link(model, attr_type, "", element, attr_name)

+ 21 - 6
integration/utils.py

@@ -180,7 +180,7 @@ def run_file(files, parameters, expected, mode):
             kill(proc)
         except UnboundLocalError:
             pass
-            
+
 def run_barebone(parameters, expected, interface="0", timeout=False, wait=False, link=None, inputs=[]):
     port = getFreePort()
     address = "http://localhost:%i" % port
@@ -192,6 +192,11 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
         timeout_val = 15
         start = time.time()
         while 1:
+            proc.poll()
+            if proc.returncode is not None:
+                # Modelverse has already terminated, which isn't a good sign!
+                return False
+
             try:
                 urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % username, "username": "user_manager"})), timeout=1).read()
                 if interface is not None:
@@ -200,10 +205,6 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
             except:
                 time.sleep(0.01)
 
-                if proc.returncode is not None:
-                    # Modelverse has already terminated, which isn't a good sign!
-                    return False
-
                 if time.time() - start > timeout_val:
                     raise
 
@@ -214,12 +215,13 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
             if isinstance(p, int):
                 if p not in var_list:
                     data = flush_data(address, data)
-                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
 
+                    proc.poll()
                     if proc.returncode is not None:
                         # Modelverse has already terminated, which isn't a good sign!
                         return False
 
+                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
                     val = val.split("=", 2)[1].split("&", 1)[0]
                     var_list[p] = val
                     continue
@@ -246,9 +248,17 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                     kill(proc2)
                     print("Linking timeout expired!")
                     return False
+                if proc.returncode is not None:
+                    # Modelverse has already terminated, which isn't a good sign!
+                    return False
+
 
         for inp in inputs:
             urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": inp, "username": username})), timeout=1).read()
+            proc.poll()
+            if proc.returncode is not None:
+                # Modelverse has already terminated, which isn't a good sign!
+                return False
 
         counter = 0
         for e in expected:
@@ -257,6 +267,11 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
             for _ in range(c):
                 try:
                     val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=15).read()
+                    proc.poll()
+                    if proc.returncode is not None:
+                        # Modelverse has already terminated, which isn't a good sign!
+                        return False
+
                 except:
                     if timeout:
                         return True