Skip to content

Commit

Permalink
Add a test for #410
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Feb 10, 2017
1 parent a909085 commit 23047b8
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions test/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
class TestExecute(unittest.TestCase):
def setUp(self):
env.reset()
self.resetDir('.sos')
subprocess.call('sos remove -s', shell=True)
#self.resetDir('~/.sos')
self.temp_files = []

def tearDown(self):
Expand All @@ -57,9 +58,9 @@ def touch(self, files):
self.temp_files.extend(files)

def resetDir(self, dirname):
if os.path.isdir(dirname):
shutil.rmtree(dirname)
os.mkdir(dirname)
if os.path.isdir(os.path.expanduser(dirname)):
shutil.rmtree(os.path.expanduser(dirname))
os.mkdir(os.path.expanduser(dirname))

def testCommandLine(self):
'''Test command line arguments'''
Expand Down Expand Up @@ -1992,5 +1993,42 @@ def testStoppedOutput(self):
self.assertTrue(FileTarget("{}.txt".format(idx)).exists())
FileTarget("${idx}.txt").remove('both')

def testSignatureWithVars(self):
'''Test revaluation with variable change'''
st = time.time()
script = SoS_Script('''
parameter: DB = {'input': ['a1.out'], 'output': ['b2.out']}
parameter: input_file = DB['input']
parameter: output_file = DB['output']
[2]
input: input_file, group_by = 1
output: output_file[_index]
run:
sleep 2
touch ${_output}
''')
wf = script.workflow()
Base_Executor(wf).run()
self.assertGreater(time.time() - st, 2)
#
st = time.time()
script = SoS_Script('''
parameter: DB = {'input': ['a1.out', 'a2.out'], 'output': ['b2.out', 'b1.out']}
parameter: input_file = DB['input']
parameter: output_file = DB['output']
[2]
input: input_file, group_by = 1
output: output_file[_index]
run:
sleep 2
touch ${_output}
''')
wf = script.workflow()
Base_Executor(wf).run()
self.assertLess(time.time() - st, 4)
self.assertGreater(time.time() - st, 2)

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

0 comments on commit 23047b8

Please sign in to comment.