Переглянути джерело

Fixed various problems; test passes again

Yentl Van Tendeloo 8 роки тому
батько
коміт
42bec84f2d

+ 5 - 1
bootstrap/conformance_finding.alc

@@ -16,7 +16,6 @@ Boolean function find_type_mapping(model : Element):
 	String elem
 
 	tm = get_type_mapping_as_dict(model)
-	log("Got type mapping: " + cast_e2s(tm))
 
 	// 1) remove elements from type mapping that are not in the model or metamodel
 	elems = dict_keys(tm)
@@ -31,7 +30,12 @@ Boolean function find_type_mapping(model : Element):
 				dict_delete(tm, elem)
 		
 	// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
+	// TODO this must be expanded for other things than trivial metamodels!
 	if (dict_len(model["model"]) > dict_len(tm)):
+		log("Model is incompletely typed!")
+		log("Model has: " + set_to_string(dict_keys(model["model"])))
+		log("Type mapping has: " + set_to_string(dict_keys(tm)))
+		log("Missing: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
 
 		// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
 		//      and it makes the assumption that SCD is the M3 level...

+ 4 - 6
bootstrap/core_algorithm.alc

@@ -72,7 +72,6 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		Element mm
 		mm = get_full_model(metamodel_id, get_model_id("SimpleClassDiagrams"))
 		if (element_eq(mm, read_root())):
-			log("Metamodel is broken!")
 			return read_root()!
 		else:
 			dict_add(m, "metamodel", mm)
@@ -81,8 +80,6 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		if (set_len(allAssociationDestinations(core, choice, "typing")) == 1):
 			// Add the preferred original type mapping
 			dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
-			log("Imported type mapping with ID " + cast_e2s(m["type_mapping"]))
-			log("Location was: " + cast_e2s(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
 		else:
 			// Start from scratch
 			dict_add(m, "type_mapping", new_type_mapping())
@@ -95,6 +92,8 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 		return m!
 	else:
 		log("No type mapping could be deduced!")
+		log("Error for " + cast_v2s(read_attribute(core, model_id, "name")))
+		log(" and type " + cast_v2s(read_attribute(core, metamodel_id, "name")))
 		return read_root()!
 
 Integer function get_relation_to_model(user_id : String, model_id : String):
@@ -280,7 +279,6 @@ String function export_typing(model : Element, name : String, user_id : String):
 	String location
 	location = "type_mappings/" + cast_id2s(model["type_mapping"])
 	export_node(location, model["type_mapping"])
-	log("Export typing information to " + location)
 
 	String instance_of
 	instantiate_attribute(core, result, "name", "TM_" + name)
@@ -434,7 +432,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 			set_add_node(model_tuples, create_tuple(key, mm))
 
 		Element merged_metamodel
-		merged_metamodel = get_full_model(get_model_id(merged_metamodel_id), get_model_id("SimpleClassDiagrams"))
+		merged_metamodel = get_full_model(merged_metamodel_id, get_model_id("SimpleClassDiagrams"))
 		if (element_eq(merged_metamodel, read_root())):
 			log("Merged metamodel in operation is not of type SimpleClassDiagrams")
 			output("Merged metamodel in operation is not of type SimpleClassDiagrams")
@@ -1204,8 +1202,8 @@ String function transformation_add(user_id : String, source_models : Element, ta
 					if (element_eq(mm, read_root())):
 						return "Transformation target type not in SimpleClassDiagrams hierarchy: " + key!
 
-					set_add_node(formalism_map, create_tuple(key, mm))
 					if (bool_not(set_in(all_formalisms, model_id))):
+						set_add_node(formalism_map, create_tuple(key, mm))
 						set_add(all_formalisms, model_id)
 				else:
 					return "Name already selected for target: " + key!

+ 15 - 2
bootstrap/semi_primitives.alc

@@ -264,8 +264,6 @@ Element function set_overlap(sa : Element, sb : Element):
 
 	result = set_create()
 	sa = set_copy(sa)
-	//log("SA: " + set_to_string(sa))
-	//log("SB: " + set_to_string(sb))
 
 	// Iterate over each element of sa and only add it to the result if it is also in sb
 	while (set_len(sa) > 0):
@@ -428,3 +426,18 @@ Element function dict_values(dict : Element):
 		set_add(result, dict[set_pop(keys)])
 
 	return result!
+
+Element function set_difference(sa : Element, sb : Element):
+	Element result
+	Element elem
+
+	result = set_copy(sa)
+	sb = set_copy(sb)
+
+	while (set_len(sb) > 0):
+		elem = set_pop(sb)
+		if (set_in(sa, elem)):
+			// Shared between both
+			set_remove(result, elem)
+
+	return result!

+ 0 - 3
bootstrap/typing.alc

@@ -17,13 +17,10 @@ String function read_type(model : Element, name : String):
 			if (dict_in(model["metamodel"]["model"], result)):
 				return result!
 			else:
-				// log("Could not find " + result)
 				return ""!
 		else:
-			// log("Untyped " + name)
 			return ""!
 	else:
-		// log("Couldn't find type of " + name)
 		return ""!
 
 Void function retype(model : Element, element : String, type : String):

+ 3 - 2
integration/utils.py

@@ -18,8 +18,6 @@ from hutn_compiler.compiler import main as do_compile
 taskname = "test_task"
 INIT_TIMEOUT = 30
 
-
-
 try:
     import pytest
     slow = pytest.mark.skipif(
@@ -55,9 +53,12 @@ def execute(scriptname, parameters=[], wait=False):
 
 def child_kill(pid):
     subprocess.call(["pkill", "-P", "%i" % pid])
+    start = time.time()
     with open(os.devnull, 'w') as null:
         while subprocess.call(["pgrep", "-P", "%i" % pid], stdout=null) != 1:
             time.sleep(0.1)
+            if time.time() > start + 4:
+                subprocess.call(["pkill", "-9", "-P", "%i" % pid])
 
 def kill(process):
     if os.name == "nt":

+ 1 - 0
interface/HUTN/includes/primitives.alh

@@ -108,6 +108,7 @@ String function set_to_string(set : Element)
 String function list_to_string(set : Element)
 String function dict_to_string(dict : Element)
 Element function set_overlap(sa : Element, sb : Element)
+Element function set_difference(sa : Element, sb : Element)
 Element function set_equality(sa : Element, sb : Element)
 Element function dict_eq(da : Element, db : Element)
 Element function dict_copy(dict : Element)