def setUp(self): super(IsolateServerArchiveSmokeTest, self).setUp() # The namespace must end in '-gzip' since all files are now compressed # before being uploaded. # TODO(maruel): This should not be leaked to the client. It's a # transport/storage detail. self.namespace = ('temporary' + str(long(time.time())).split('.', 1)[0] + '-gzip') self.tempdir = tempfile.mkdtemp(prefix=u'isolateserver') self.rootdir = os.path.join(self.tempdir, 'rootdir') self.test_data = os.path.join(self.tempdir, 'test_data') test_utils.make_tree(self.test_data, CONTENTS)
def test_run_mixed(self): # Test when a user mapped from a directory and then replay from another # directory. This is a very rare corner case. indir = os.path.join(self.tempdir, 'input') test_utils.make_tree(indir, SIMPLE_ISOLATE) proc = subprocess.Popen([ sys.executable, 'isolate.py', 'check', '-i', os.path.join(indir, 'simple.isolate'), '-s', os.path.join(indir, 'simple.isolated'), '--config-variable', 'OS', 'mac', ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=ROOT_DIR) stdout = proc.communicate()[0] self.assertEqual('', stdout) self.assertEqual(0, proc.returncode) expected = [ 'simple.isolate', 'simple.isolated', 'simple.isolated.state', 'simple.py', ] self.assertEqual(expected, sorted(os.listdir(indir))) # Remove the original directory. indir2 = indir + '2' os.rename(indir, indir2) # simple.isolated.state is required; it contains the variables. proc = subprocess.Popen([ sys.executable, 'isolate.py', 'run', '-s', os.path.join(indir2, 'simple.isolated'), '--skip-refresh', ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=ROOT_DIR, universal_newlines=True) stdout = proc.communicate()[0] self.assertEqual(1, proc.returncode) self.assertTrue('simple.py is missing' in stdout)
def test_run_mixed(self): # Test when a user mapped from a directory and then replay from another # directory. This is a very rare corner case. indir = os.path.join(self.tempdir, 'input') test_utils.make_tree(indir, SIMPLE_ISOLATE) proc = subprocess.Popen( [ sys.executable, 'isolate.py', 'check', '-i', os.path.join(indir, 'simple.isolate'), '-s', os.path.join(indir, 'simple.isolated'), '--config-variable', 'OS', 'mac', ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=ROOT_DIR) stdout = proc.communicate()[0] self.assertEqual('', stdout) self.assertEqual(0, proc.returncode) expected = [ 'simple.isolate', 'simple.isolated', 'simple.isolated.state', 'simple.py', ] self.assertEqual(expected, sorted(os.listdir(indir))) # Remove the original directory. indir2 = indir + '2' os.rename(indir, indir2) # simple.isolated.state is required; it contains the variables. proc = subprocess.Popen( [ sys.executable, 'isolate.py', 'run', '-s', os.path.join(indir2, 'simple.isolated'), '--skip-refresh', ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=ROOT_DIR, universal_newlines=True) stdout = proc.communicate()[0] self.assertEqual(1, proc.returncode) self.assertTrue('simple.py is missing' in stdout)
def make_tree(self, contents): test_utils.make_tree(self.tempdir, contents)
def make_tree(self, case=None): case = case or self.case() if not case: return test_utils.make_tree(self.isolate_dir, DEPENDENCIES[case][0])