Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for LIST remove_item and remove_at commands, LIST inser… #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ __pycache__/
graph.gv
graph.gv.pdf
*.log
.venv
.venv
venv
20 changes: 20 additions & 0 deletions datastructs.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,26 @@ def evaluate(self, conditions, recStack, lookup=None):
recStack=recStack)
return result

if 'remove_item' in self.getName().lower():
print("hello!")
inspiring71 marked this conversation as resolved.
Show resolved Hide resolved
arguments = flattenAlgorithmWithConditions(self.commands[0].getChildren(),conditions, recStack=recStack)
result = flattenAlgorithmWithConditions(self.depends[0],conditions, recStack=recStack)
for argument in arguments:
for item in result:
if item[0] == argument.getValue():
result=[i for i in result if i != item]
inspiring71 marked this conversation as resolved.
Show resolved Hide resolved
print('result',result)
return result;

if 'remove_at' in self.getName().lower():
arguments = self.commands[0].getChildren()
result = flattenAlgorithmWithConditions(self.depends[0],conditions, recStack=recStack)
for argument in arguments:
del result[argument.getValue()]
return result;




class ConcatNode(Node):
def __init__(self, name: str):
Expand Down
8 changes: 8 additions & 0 deletions test/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"BUILD_SERVER:True && FEATURE_IRC_SERVER:True": [
"files_for_test/b.cxx"
],
"NO_MATTER_WHAT": [
"files_for_test/a.cxx"
]
}
Binary file added test/result.pkl
Binary file not shown.
52 changes: 51 additions & 1 deletion test/variable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ def test_list_remove_variable(self):
list(REMOVE_ITEM foo b)
"""
self.runTool(text)
# self.vmodel.export()
self.vmodel.export()

def test_variable_growth(self):
text = """
Expand Down Expand Up @@ -1913,5 +1913,55 @@ def test_sample_1(self):
"""
self.runTool(text)


def test_conditional_list_remove_variable(self):
inspiring71 marked this conversation as resolved.
Show resolved Hide resolved
text = """
option(opt1 "des1" YES)
set(foo john doe bar)
if(opt1)
list(REMOVE_ITEM foo john boo)
endif()
"""
self.runTool(text)
var = self.lookup.getKey('${foo}')
a = flattenAlgorithmWithConditions(var)
self.vmodel.export()
inspiring71 marked this conversation as resolved.
Show resolved Hide resolved

def test_complex_conditional_list_remove_variable(self):
text = """
option(opt1 "des" YES)
option(opt2 "des" YES)

set(var_a foo bar john doe)
if(opt1)
list(REMOVE_ITEM var_a bar Farshad)
elseif(opt2)
list(REMOVE_ITEM var_a john Mehran)
endif()
"""
self.runTool(text)
self.vmodel.export()


def test_remove_at_conditional_list_remove_variable(self):
text = """
set(var_a foo bar john doe)
set(item 2)
list(REMOVE_AT var_a ${item})
"""
self.runTool(text)
self.vmodel.export()


def test_insert_list_remove_variable(self):
# TODO: need implementation
text = """
set(var_a foo bar john doe)
set(item foo)
list(INSERT var_a ${item})
"""
self.runTool(text)
self.vmodel.export()

if __name__ == '__main__':
unittest.main()