コード例 #1
0
def test_error_guessing_redundancies_case_2() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_3], 1, 1)
    relation_3 = Relation(feature_1, [feature_4], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)
    feature_1.add_relation(relation_3)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("C")
    node_1.right = Node("B")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.REQUIRES)
    node_2.left = Node("D")
    node_2.right = Node("B")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "error-guessing/redundancies/case2/r-case2")
    run(path, model)
コード例 #2
0
def test_relationships_optional() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)

    feature_1.add_relation(relation_1)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/optional/optional")
    run(path, model)
コード例 #3
0
def test_relationships_mandatory() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)

    feature_1.add_relation(relation_1)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/mandatory/mandatory")
    run(path, model)
コード例 #4
0
 def add_feature(self, relation, word, model) -> None:
     if word in self.name_feature:
         print("This AFM contains duplicated feature names", file=sys.stderr)
         raise DuplicatedFeature
     feature = Feature(word, [])
     model.features.append(feature)
     self.name_feature[word] = feature
     relation.children.append(feature)
コード例 #5
0
 def process_feature(self, f: Feature):
     _dict = {}
     _dict["featureName"] = f.name
     relationships = []
     for relation in f.get_relations():
         relationships.append(self.process_relation(relation))
     _dict["relationships"] = relationships
     return _dict
コード例 #6
0
def test_refinement_optional_alternative_valid_p() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)

    feature_1.add_relation(relation_1)

    relation_2 = Relation(feature_2, [feature_3, feature_4], 1, 1)

    feature_2.add_relation(relation_2)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "refinement/optional-alternativeValidP/optional-alternativeVP")
    run(path, model)
コード例 #7
0
def test_error_guessing_core_features_case_2() -> None:
    feature_1 = Feature("A", None, None, False)
    feature_2 = Feature("B", None, None, False)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)

    feature_1.add_relation(relation_1)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("A")
    node_1.right = Node("B")
    ast_1 = AST(node_1)

    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path("error-guessing/core-features/case2/cf-case2")
    run(path, model)
コード例 #8
0
def test_relationships_requires_excludes() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_3], 0, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.EXCLUDES)
    node_2.left = Node("B")
    node_2.right = Node("C")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_1", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "relationships/requires-excludes/requires-excludes")
    run(path, model)
コード例 #9
0
def test_error_guessing_dead_features_case_8() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, False)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_3], 0, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    node_1 = Node(ASTOperation.EXCLUDES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.REQUIRES)
    node_2.left = Node("B")
    node_2.right = Node("C")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_1", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path("error-guessing/dead-features/case8/df-case8")
    run(path, model)
コード例 #10
0
    def parse_features(self, words: list[str], model: FeatureModel) -> Feature:
        name = words[0].replace(':', '')
        words.pop(0)

        if name in self.parents:
            print('This AFM contains duplicated feature names',
                  file=sys.stderr)
            raise DuplicatedFeature
        self.parents.append(name)

        feature_parent = Feature(name, [])
        if name in self.name_feature:
            feature_parent = self.name_feature[name]
        else:
            model.features.append(feature_parent)
            model.root = feature_parent
            self.name_feature[name] = feature_parent

        is_grouped = False
        is_or = False
        for word in words:
            if is_grouped:
                if is_or:
                    relation.card_max += 1
                if word.__contains__('}'):
                    word = word.replace('}', '').replace(';', '')
                    self.add_feature(relation, word, model)
                    is_or = False
                    is_grouped = False
                else:
                    word = word.replace('{', '').replace(';', '')
                    self.add_feature(relation, word, model)
            else:
                if word.__contains__('[1,'):
                    is_grouped = True
                    relation = self.parse_relation('Alternative/Or',
                                                   feature_parent)
                    if not word.__eq__('[1,1]'):
                        relation.card_max = 0
                        is_or = True
                    continue
                elif word.__contains__('[') and word.__contains__(']'):
                    relation = self.parse_relation('Optional', feature_parent)
                    word = word.replace('[', '').replace(']',
                                                         '').replace(';', '')
                    self.add_feature(relation, word, model)
                else:
                    relation = self.parse_relation('Mandatory', feature_parent)
                    word = word.replace(';', '')
                    self.add_feature(relation, word, model)
            model.relations.append(relation)
        return feature_parent
コード例 #11
0
    def genetare_data_test_cases(self) -> dict[FeatureModel, list[list[str]]]:
        result = {}

        while True:
            features = self.fm.get_features()
            num = len(features)
            new_feature1 = Feature("F" + str(self.feature_counter), [])
            self.feature_counter += 1
            new_feature2 = Feature("F" + str(self.feature_counter), [])

            f_number1 = random.randrange(num)
            f_number2 = random.randrange(num)
            while f_number1 == f_number2:
                f_number2 = random.randrange(num)

            number = random.randrange(1, 7)
            if number == 1:
                self.add_mandatory(new_feature1)
            elif number == 2:
                self.add_optional(new_feature1)
            elif number == 3:
                self.add_alternative(new_feature1, new_feature2)
            elif number == 4:
                self.add_or(new_feature1, new_feature2)
            elif number == 5:
                self.add_requires(features[f_number1], features[f_number2])
            else:
                self.add_excludes(features[f_number1], features[f_number2])

            result[copy.deepcopy(self.fm)] = copy.deepcopy(self.products)

            if self.iteration_counter == self.iterations:
                print("The number of desired features has been marked!")
                break
            self.iteration_counter += 1

        return result
コード例 #12
0
def test_relationships_alternative() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2, feature_3], 1, 1)

    feature_1.add_relation(relation_1)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/alternative/alternative")
    run(path, model)
コード例 #13
0
    def parse_feature(self, element) -> Feature:
        name = element.attrib.get('name')

        feature = Feature(name, [])

        if name in self.name_feature:
            print("This XML contains duplicated feature names",
                  file=sys.stderr)
            raise DuplicatedFeature

        self.name_feature[name] = feature

        for child in element:
            if child.tag.casefold() == 'setrelation' or child.tag.casefold(
            ) == 'binaryrelation':
                relation = self.parse_relation(child)
                relation.parent = feature
                feature.relations.append(relation)
        return feature
コード例 #14
0
    def parse_features(self, words: list[str], model: FeatureModel) -> Feature:
        name = words[0].replace(":", "")
        words.pop(0)

        if name in self.parents:
            print("This AFM contains duplicated feature names", file=sys.stderr)
            raise DuplicatedFeature
        self.parents.append(name)

        feature_parent = Feature(name, [])
        if name in self.name_feature:
            feature_parent = self.name_feature[name]
        else:
            model.features.append(feature_parent)
            model.root = feature_parent
            self.name_feature[name] = feature_parent

        alternative_rel = "[1,1]"
        or_rel = "[1," + str(len(words) - 1) + "]"
        if words.__contains__(alternative_rel) or words.__contains__(or_rel):
            if words.__contains__(alternative_rel):
                words.remove(alternative_rel)
                relation = self.parse_relation("Alternative", feature_parent)
            elif words.__contains__(or_rel):
                words.remove(or_rel)
                relation = self.parse_relation("Or", feature_parent, len(words))
            model.relations.append(relation)
            for word in words:
                word = word.replace("{", "").replace("}", "").replace(";", "")
                self.add_feature(relation, word, model)
        else:
            for word in words:
                if word.__contains__("[") and word.__contains__("]"):
                    relation = self.parse_relation("Optional", feature_parent)
                    word = word.replace("[", "").replace("]", "").replace(";", "")
                    self.add_feature(relation, word, model)
                else:
                    relation = self.parse_relation("Mandatory", feature_parent)
                    word = word.replace(";", "")
                    self.add_feature(relation, word, model)
                model.relations.append(relation)
        return feature_parent
コード例 #15
0
    def transform(self):
        with open(self.path, 'r') as lines:
            lines = [line.strip() for line in lines.readlines() if line.strip() != ""]
        for line in lines:
            if line.__contains__("%Relationships"):
                index_r = lines.index(line)
            if line.__contains__("%Constraints"):
                index_c = lines.index(line)
        relations = lines[index_r + 1:index_c]
        constraints = lines[index_c + 1:]

        feature_model = FeatureModel(Feature("", []))
        for relation in relations:
            words = relation.split(" ")
            self.parse_features(words, feature_model)

        for constraint in constraints:
            constraint = constraint.replace(";", "")
            ctc = self.parse_ctc(constraint)
            feature_model.ctcs.append(ctc)

        return feature_model
コード例 #16
0
def test_relationships_or_excludes() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2, feature_3], 1, 2)

    feature_1.add_relation(relation_1)

    node_1 = Node(ASTOperation.EXCLUDES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path(
        "relationships/or-excludes/or-excludes")
    run(path, model)
コード例 #17
0
def test_error_guessing_false_optional_features_case_5() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, False)

    relation_1 = Relation(feature_1, [feature_2, feature_3], 1, 2)

    feature_1.add_relation(relation_1)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path(
        "error-guessing/false-optional-features/case5/fof-case5")
    run(path, model)
コード例 #18
0
def test_relationships_alternative_requires() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2, feature_3], 1, 1)

    feature_1.add_relation(relation_1)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path(
        "relationships/alternative-requires/alternative-requires")
    run(path, model)
コード例 #19
0
def test_error_guessing_core_features_case_6() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    node_1 = Node(ASTOperation.EXCLUDES)
    node_1.left = Node("B")
    node_1.right = Node("C")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path("error-guessing/core-features/case6/cf-case6")
    run(path, model)
コード例 #20
0
def test_relationships_allrelationships() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)
    feature_6 = Feature("F", None, None, True)
    feature_7 = Feature("G", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3], 0, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_4, feature_5], 1, 1)

    feature_2.add_relation(relation_3)

    relation_4 = Relation(feature_3, [feature_6, feature_7], 1, 2)

    feature_3.add_relation(relation_4)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("E")
    node_1.right = Node("F")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.EXCLUDES)
    node_2.left = Node("D")
    node_2.right = Node("G")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "relationships/allrelationships/allrelationships")
    run(path, model)
コード例 #21
0
def test_refinement_or_no_alternative() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, False)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_5], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_3, feature_4], 1, 2)

    feature_2.add_relation(relation_3)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("E")
    node_1.right = Node("D")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.REQUIRES)
    node_2.left = Node("E")
    node_2.right = Node("C")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "refinement/or-noAlternative/or-noAlternative")
    run(path, model)
コード例 #22
0
def test_refinement_df_alternative_excludes() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, False)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3], 0, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_3, [feature_4, feature_5], 1, 1)

    feature_3.add_relation(relation_3)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("B")
    node_1.right = Node("D")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path(
        "refinement/df-alternative-excludes/df-alternative-excludes")
    run(path, model)
コード例 #23
0
def test_relationships_mandatory_optional() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3], 0, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_4], 0, 1)

    feature_2.add_relation(relation_3)

    relation_4 = Relation(feature_3, [feature_5], 1, 1)

    feature_3.add_relation(relation_4)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/mandatory-optional/mandatory-optional")
    run(path, model)
コード例 #24
0
def test_error_guessing_false_optional_features_case_6() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, False)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, False)
    feature_6 = Feature("F", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_3], 1, 1)
    relation_3 = Relation(feature_1, [feature_4], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)
    feature_1.add_relation(relation_3)

    relation_4 = Relation(feature_3, [feature_5, feature_6], 1, 1)

    feature_3.add_relation(relation_4)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("E")
    node_1.right = Node("B")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.EXCLUDES)
    node_2.left = Node("D")
    node_2.right = Node("F")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "error-guessing/false-optional-features/case6/fof-case6")
    run(path, model)
コード例 #25
0
def test_error_guessing_dead_features_case_3() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, False)
    feature_5 = Feature("E", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_3, [feature_4, feature_5], 1, 2)

    feature_3.add_relation(relation_3)

    node_1 = Node(ASTOperation.EXCLUDES)
    node_1.left = Node("D")
    node_1.right = Node("B")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    model = FeatureModel(feature_1, [ctc_1])
    path = normalize_path("error-guessing/dead-features/case3/df-case3")
    run(path, model)
コード例 #26
0
def test_relationships_optional_or() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)
    feature_6 = Feature("F", None, None, True)
    feature_7 = Feature("G", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_3, feature_4], 1, 2)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_5, feature_6], 1, 2)

    feature_2.add_relation(relation_3)

    relation_4 = Relation(feature_3, [feature_7], 0, 1)

    feature_3.add_relation(relation_4)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/optional-or/optional-or")
    run(path, model)
コード例 #27
0
def test_refinement_alternative_no_parent_last_child() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 0, 1)
    relation_2 = Relation(feature_1, [feature_5], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_3, feature_4], 1, 1)

    feature_2.add_relation(relation_3)

    node_1 = Node(ASTOperation.EXCLUDES)
    node_1.left = Node("E")
    node_1.right = Node("B")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.REQUIRES)
    node_2.left = Node("E")
    node_2.right = Node("D")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "refinement/alternative-noParentLastChild/alternative-noParentLastChild")
    run(path, model)
コード例 #28
0
def test_refinement_alternative_odd_children() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)
    feature_6 = Feature("F", None, None, True)
    feature_7 = Feature("G", None, None, True)
    feature_8 = Feature("H", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_8], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(
        feature_2, [feature_3, feature_4, feature_5, feature_6, feature_7], 1, 1)

    feature_2.add_relation(relation_3)

    node_1 = Node(ASTOperation.REQUIRES)
    node_1.left = Node("H")
    node_1.right = Node("G")
    ast_1 = AST(node_1)
    ctc_1 = Constraint("ctc_1", ast_1)

    node_2 = Node(ASTOperation.REQUIRES)
    node_2.left = Node("H")
    node_2.right = Node("E")
    ast_2 = AST(node_2)
    ctc_2 = Constraint("ctc_2", ast_2)

    model = FeatureModel(feature_1, [ctc_1, ctc_2])
    path = normalize_path(
        "refinement/alternative-oddChildren/alternative-oddChildren")
    run(path, model)
コード例 #29
0
def test_relationships_mandatory_alternative() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)
    feature_6 = Feature("F", None, None, True)
    feature_7 = Feature("G", None, None, True)

    relation_1 = Relation(feature_1, [feature_2], 1, 1)
    relation_2 = Relation(feature_1, [feature_3, feature_4], 1, 1)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_5, feature_6], 1, 1)

    feature_2.add_relation(relation_3)

    relation_4 = Relation(feature_3, [feature_7], 1, 1)

    feature_3.add_relation(relation_4)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/mandatory-alternative/mandatory-alternative")
    run(path, model)
コード例 #30
0
def test_relationships_or_alternative() -> None:
    feature_1 = Feature("A", None, None, True)
    feature_2 = Feature("B", None, None, True)
    feature_3 = Feature("C", None, None, True)
    feature_4 = Feature("D", None, None, True)
    feature_5 = Feature("E", None, None, True)
    feature_6 = Feature("F", None, None, True)
    feature_7 = Feature("G", None, None, True)
    feature_8 = Feature("H", None, None, True)
    feature_9 = Feature("I", None, None, True)

    relation_1 = Relation(feature_1, [feature_2, feature_3], 1, 1)
    relation_2 = Relation(feature_1, [feature_4, feature_5], 1, 2)

    feature_1.add_relation(relation_1)
    feature_1.add_relation(relation_2)

    relation_3 = Relation(feature_2, [feature_6, feature_7], 1, 2)

    feature_2.add_relation(relation_3)

    relation_4 = Relation(feature_5, [feature_8, feature_9], 1, 1)

    feature_5.add_relation(relation_4)

    model = FeatureModel(feature_1)
    path = normalize_path(
        "relationships/or-alternative/or-alternative")
    run(path, model)