def test_diystage_path_valid(self, tmpdir): """Ensure DIYStage for a valid path behaves as expected.""" path = str(tmpdir) stage = DIYStage(path) assert stage.path == path assert stage.source_path == path # Order doesn't really matter for DIYStage since they are # basically NOOPs; however, call each since they are part # of the normal stage usage and to ensure full test coverage. stage.create() # Only sets the flag value assert stage.created stage.cache_local() # Only outputs a message stage.fetch() # Only outputs a message stage.check() # Only outputs a message stage.expand_archive() # Only outputs a message assert stage.expanded # The path/source_path does exist with pytest.raises(spack.stage.RestageError): stage.restage() stage.destroy() # A no-op assert stage.path == path # Ensure can still access attributes assert os.path.exists(stage.source_path) # Ensure path still exists
def test_restage(self, mock_archive): with Stage(mock_archive.url, name=self.stage_name) as stage: stage.fetch() stage.expand_archive() with working_dir(stage.source_path): check_expand_archive(stage, self.stage_name, mock_archive) # Try to make a file in the old archive dir with open('foobar', 'w') as file: file.write("this file is to be destroyed.") assert 'foobar' in os.listdir(stage.source_path) # Make sure the file is not there after restage. stage.restage() check_fetch(stage, self.stage_name) assert 'foobar' not in os.listdir(stage.source_path) check_destroy(stage, self.stage_name)
def test_restage(self, mock_archive): with Stage(mock_archive.url, name=self.stage_name) as stage: stage.fetch() stage.expand_archive() with working_dir(stage.source_path): check_expand_archive(stage, self.stage_name, mock_archive) # Try to make a file in the old archive dir with open('foobar', 'w') as file: file.write("this file is to be destroyed.") assert 'foobar' in os.listdir(stage.source_path) # Make sure the file is not there after restage. stage.restage() check_fetch(stage, self.stage_name) assert 'foobar' not in os.listdir(stage.source_path) check_destroy(stage, self.stage_name)
def test_restage(self): with Stage(self.archive_url, name=self.stage_name) as stage: stage.fetch() stage.expand_archive() stage.chdir_to_source() self.check_expand_archive(stage, self.stage_name) self.check_chdir_to_source(stage, self.stage_name) # Try to make a file in the old archive dir with open('foobar', 'w') as file: file.write("this file is to be destroyed.") self.assertTrue('foobar' in os.listdir(stage.source_path)) # Make sure the file is not there after restage. stage.restage() self.check_chdir(stage, self.stage_name) self.check_fetch(stage, self.stage_name) stage.chdir_to_source() self.check_chdir_to_source(stage, self.stage_name) self.assertFalse('foobar' in os.listdir(stage.source_path)) self.check_destroy(stage, self.stage_name)