Browse Source

Patching tests to include one for the MvC

Yentl Van Tendeloo 7 years ago
parent
commit
ccc3997c41
5 changed files with 30 additions and 4 deletions
  1. 4 0
      bootstrap/metamodels.alc
  2. 4 0
      bootstrap/modelling.alc
  3. 1 0
      core/core_algorithm.alc
  4. 13 3
      integration/utils.py
  5. 8 1
      scripts/compile.py

+ 4 - 0
bootstrap/metamodels.alc

@@ -146,6 +146,10 @@ Element function constraint_call(model : Element, name : String):
 		return "Expected physical action value"!
 
 Element function initialize_SCD(location : String):
+	log("INITIALIZE SCD AT " + location)
+	if (import_node(location) != read_root()):
+		return import_node(location)!
+
 	Element scd
 	scd = instantiate_bottom()
 

+ 4 - 0
bootstrap/modelling.alc

@@ -454,6 +454,10 @@ Void function add_constraint(model : Element, element : String, constraint : Act
 
 Void function construct_model():
 	String command
+
+	log("Constructing model")
+	initialize_SCD("models/SimpleClassDiagrams")
+
 	while (True):
 		command = input()
 		if (command == "instantiate_bottom"):

+ 1 - 0
core/core_algorithm.alc

@@ -8,6 +8,7 @@ include "model_management.alh"
 include "ramify.alh"
 include "conformance_scd.alh"
 include "transform.alh"
+include "metamodels.alh"
 
 Element core = ?
 

+ 13 - 3
integration/utils.py

@@ -114,7 +114,9 @@ def run_file(files, parameters, expected, mode):
         threads = []
         mod_files = []
         for filename in files:
-            if os.path.isfile("integration/code/%s" % filename):
+            if os.path.isfile(filename):
+                mod_filename = filename
+            elif os.path.isfile("integration/code/%s" % filename):
                 mod_filename = "integration/code/%s" % filename
             elif os.path.isfile("bootstrap/%s" % filename):
                 mod_filename = "bootstrap/%s" % filename
@@ -125,12 +127,19 @@ def run_file(files, parameters, expected, mode):
         to_compile = to_recompile(address, mod_files)
 
         for mod_filename in to_compile:
+            if mod_filename.endswith(".mvc"):
+                model_mode = "MO"
+            else:
+                model_mode = mode
+            print("COMPILE " + mod_filename)
+            print(" as " + model_mode)
+            mod_files.remove(mod_filename)
             if parallel_push:
                 import threading
-                threads.append(threading.Thread(target=compile_file, args=[address, mod_filename, mod_filename, mode, proc]))
+                threads.append(threading.Thread(target=compile_file, args=[address, mod_filename, mod_filename, model_mode, proc]))
                 threads[-1].start()
             else:
-                compile_file(address, mod_filename, mod_filename, mode, proc)
+                compile_file(address, mod_filename, mod_filename, model_mode, proc)
 
         if parallel_push:
             for t in threads:
@@ -138,6 +147,7 @@ def run_file(files, parameters, expected, mode):
 
         if mode[-1] == "O":
             # Fire up the linker
+            print("Linking " + mod_files)
             val = execute("link_and_load", [address, username] + mod_files, wait=True)
             if val != 0:
                 raise Exception("Linking error")

+ 8 - 1
scripts/compile.py

@@ -4,8 +4,15 @@ import urllib2
 import urllib
 import subprocess
 
-def do_compile(address, filename, username, modulename, mode, optionals=['--debug'], grammar="grammars/actionlanguage.g"):
+def do_compile(address, filename, username, modulename, mode, optionals=['--debug'], grammar=""):
     filename = os.path.realpath(filename)
+    if grammar == "":
+        if mode[0] == "M":
+            # Load model grammar
+            grammar = "grammars/modelling.g"
+        else:
+            # Load AL grammar
+            grammar = "grammars/actionlanguage.g"
     try:
         urllib2.urlopen(urllib2.Request(address, 'op=set_input&username=user_manager&value="%s"' % username)).read()
         subprocess.check_call([sys.executable, "hutn_compiler/compiler.py", filename, grammar, mode, username, modulename, filename, address] + optionals, cwd="interface/HUTN")