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

Runtsafe order bug #1265

Merged
merged 6 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion synapse/cmds/cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _onErr(self, mesg):
text = text.replace('\n', ' ')
# Handle too-long text
if tlen > 60:
text = text[pos - 30:pos + 30]
text = text[max(0, pos - 30):pos + 30]
if pos < tlen - 30:
text += '...'
if pos > 30:
Expand Down
15 changes: 6 additions & 9 deletions synapse/lib/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,18 +522,15 @@ class VarEvalOper(Oper):
'''
async def run(self, runt, genr):

if self.isRuntSafe(runt):

async for item in genr:
yield item
anynodes = False
async for node, path in genr:
anynodes = True
await self.kids[0].compute(path)
yield node, path

if not anynodes and self.isRuntSafe(runt):
await self.kids[0].runtval(runt)

else:
async for node, path in genr:
await self.kids[0].compute(path)
yield node, path

class SwitchCase(Oper):

def prepare(self):
Expand Down
6 changes: 6 additions & 0 deletions synapse/tests/test_cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,12 @@ async def test_storm_ifstmt(self):
nodes = await core.nodes(q)
self.len(1, nodes)

async def test_storm_order(self):
q = '''[test:str=foo :hehe=bar] $tvar=$lib.text() $tvar.add(1) $tvar.add(:hehe) $lib.print($tvar.str()) '''
async with self.getTestCore() as core:
mesgs = await core.streamstorm(q).list()
self.stormIsInPrint('1bar', mesgs)

async def test_feed_splice(self):

iden = s_common.guid()
Expand Down