Forráskód Böngészése

More user-friendly error messages when tests fail

Yentl Van Tendeloo 9 éve
szülő
commit
09901779c5

+ 17 - 20
hybrid_server/classes/mvkcontroller.xml

@@ -89,28 +89,25 @@
                         <parameter name="data"/>
                         <script>
                             # No JSON encoding necessary, as it is not complex
-                            try:
-                                if data["op"] == "set_input":
-                                    if "element_type" in data:
-                                        if data["element_type"] == "V":
-                                            value = json.loads(data["value"])
-                                        else:
-                                            value = data["value"]
-                                        args = [data["element_type"], value]
-                                        self.input_queue[data["username"]].append((source, [args]))
+                            if data["op"] == "set_input":
+                                if "element_type" in data:
+                                    if data["element_type"] == "V":
+                                        value = json.loads(data["value"])
                                     else:
-                                        d = []
-                                        for t, v in json.loads(data["data"]):
-                                            if t == "V":
-                                                v = json.loads(v)
-                                            d.append([t, v])
-                                        self.input_queue[data["username"]].append((source, d))
-                                elif data["op"] == "get_output":
-                                    self.output_queue[data["username"]].append(source)
+                                        value = data["value"]
+                                    args = [data["element_type"], value]
+                                    self.input_queue[data["username"]].append((source, [args]))
                                 else:
-                                    print("DROPPING unknown operation: " + str(data["op"]))
-                            except:
-                                print("DROPPING deserialization error")
+                                    d = []
+                                    for t, v in json.loads(data["data"]):
+                                        if t == "V":
+                                            v = json.loads(v)
+                                        d.append([t, v])
+                                    self.input_queue[data["username"]].append((source, d))
+                            elif data["op"] == "get_output":
+                                self.output_queue[data["username"]].append(source)
+                            else:
+                                raise Exception("DROPPING unknown operation: " + str(data["op"]))
                         </script>
                     </transition>
                 </state>

+ 1 - 0
hybrid_server/classes/socket.xml

@@ -129,6 +129,7 @@
                                 params = dict([p.split('=') for p in data.split('&amp;')])
                                 data = {k: urllib.unquote_plus(v) for k, v in params.iteritems()}
                             except:
+                                print("Problem receiving data in socket")
                                 data = {}
                         </script>
                         <raise event="HTTP_output" scope="narrow" target="'parent'">

+ 19 - 0
integration/utils.py

@@ -68,6 +68,10 @@ def run_file(files, parameters, expected, mode):
                 while 1:
                     proc2 = execute("compile", [mod_filename, username, filename, mode], wait=False)
 
+                    if proc.returncode is not None:
+                        # Modelverse has already terminated, which isn't a good sign!
+                        raise Exception("Modelverse died!")
+
                     while proc2.returncode is None:
                         time.sleep(0.01)
                         proc2.poll()
@@ -104,6 +108,11 @@ def run_file(files, parameters, expected, mode):
                 c = len(e) if isinstance(e, set) else 1
                 for _ in range(c):
                     val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
+
+                    if proc.returncode is not None:
+                        # Modelverse has already terminated, which isn't a good sign!
+                        raise Exception("Modelverse died!")
+
                     val = val.split("=", 2)[2]
                     print("Got %s, expect %s" % (val, e))
                     if isinstance(e, set):
@@ -148,6 +157,11 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                 break
             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
 
@@ -159,6 +173,11 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                 if p not in var_list:
                     data = flush_data(data)
                     val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
+
+                    if proc.returncode is not None:
+                        # Modelverse has already terminated, which isn't a good sign!
+                        return False
+
                     val = val.split("=", 2)[1].split("&", 1)[0]
                     var_list[p] = val
                     continue

+ 7 - 2
interface/HUTN/hutn_compiler/linker.py

@@ -4,8 +4,9 @@ import urllib2
 
 def link(username, objects, fast):
     # Read out all symbol tables that are to be linked
+    definers = {}
     if not fast:
-        definers = {"main": None}
+        definers["main"] = None
         for obj in objects:
             print("[LINK] %s" % (obj))
             urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": username}))).read()
@@ -44,7 +45,11 @@ def link(username, objects, fast):
         initializers.append(start)
 
     # Bind all initializers together
-    print("[LOAD] %s:main()" % definers["main"])
+    if definers:
+        print("[LOAD] %s:main()" % definers["main"])
+    else:
+        print("[LOAD] main()")
+
     # Set interface to constructors
     commands = [("V", '1')]