Skip to content

Commit

Permalink
Fix PBS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Oct 3, 2018
1 parent 0524c48 commit 7ed5bf7
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions test/test_pbs_queue.py
Expand Up @@ -42,7 +42,8 @@ def setUp(self):

def tearDown(self):
for f in self.temp_files:
file_target(f).remove('both')
if file_target(f).exists():
file_target(f).unlink()


@unittest.skipIf(not has_docker, "Docker container not usable")
Expand Down Expand Up @@ -258,7 +259,8 @@ def testSendSymbolicLink(self):
@unittest.skipIf(not os.path.exists(os.path.expanduser('~').upper()) or not has_docker, 'Skip test for case sensitive file system')
def testCaseInsensitiveLocalPath(self):
'''Test path_map from a case insensitive file system.'''
file_target('test_pbs_queue.py.bak').remove('both')
if file_target('test_pbs_queue.py.bak').exists():
file_target('test_pbs_queue.py.bak').unlink()
with open('tt1.py', 'w') as tt1:
tt1.write('soemthing')
script = SoS_Script('''
Expand Down Expand Up @@ -312,7 +314,7 @@ def testSoSExecute(self):
def testSoSPurge(self):
'''Test purge tasks'''
# purge all previous tasks
subprocess.check_output('sos purge -c ~/docker.yml -q ts', shell=True)
subprocess.check_output('sos purge --all -c ~/docker.yml -q ts', shell=True)
script = SoS_Script('''
[10]
input: for_each={'i': range(3)}
Expand Down Expand Up @@ -347,11 +349,11 @@ def testSoSPurge(self):

subprocess.check_output('sos purge {} -c ~/docker.yml -q ts'.format(tasks[0]), shell=True)
# there should be 2 more tasks
out = subprocess.check_output('sos status -c ~/docker.yml -q docker -v1', shell=True).decode()
out = subprocess.check_output('sos status --all -c ~/docker.yml -q docker -v1', shell=True).decode()
self.assertEqual(out.strip().count('\n'), 1, 'Expect two lines: {}'.format(out))
# show be ok
subprocess.check_output('sos purge -c ~/docker.yml -q docker', shell=True)
out = subprocess.check_output('sos status -c ~/docker.yml -q docker -v1', shell=True).decode()
out = subprocess.check_output('sos status --all -c ~/docker.yml -q docker -v1', shell=True).decode()
self.assertEqual(out.strip().count('\n'), 0)


Expand All @@ -376,7 +378,8 @@ def testRemoteInput(self):
# this file is remote only
self.assertFalse(os.path.isfile('test_file.txt'))
#
file_target('test1.txt').remove('both')
if file_target('test1.txt').exists():
file_target('test1.txt').unlink()
script = SoS_Script('''
[10]
input: remote('test_file.txt')
Expand Down Expand Up @@ -419,7 +422,8 @@ def testMultipleRemoteInput(self):
self.assertFalse(os.path.isfile('test_file_A.txt'))
self.assertFalse(os.path.isfile('test_file_B.txt'))
#
file_target('test1.txt').remove('both')
if file_target('test1.txt').exists():
file_target('test1.txt').unlink()
script = SoS_Script('''
[10]
A = 'test_file_A.txt'
Expand Down Expand Up @@ -450,8 +454,10 @@ def testMultipleRemoteInput(self):
def testRemoteOutput(self):
'''Test remote target'''
# purge all previous tasks
file_target('test_file.txt').remove('both')
file_target('test_file1.txt').remove('both')
if file_target('test_file.txt').exists():
file_target('test_file.txt').unlink()
if file_target('test_file1.txt').exists():
file_target('test_file1.txt').unlink()
script = SoS_Script('''
[10]
output: remote('test_file.txt'), 'test_file1.txt'
Expand All @@ -476,8 +482,10 @@ def testRemoteOutput(self):
def testDelayedInterpolation(self):
'''Test delayed interpolation with expression involving remote objects'''
# purge all previous tasks
file_target('test.py').remove('both')
file_target('test.py.bak').remove('both')
if file_target('test.py').exists():
file_target('test.py').unlink()
if file_target('test.py.bak').exists():
file_target('test.py.bak').unlink()
script = SoS_Script('''
[10]
output: remote('test.py')
Expand Down

0 comments on commit 7ed5bf7

Please sign in to comment.