示例#1
0
    def test_java_compile_with_corrupt_remote(self):
        """Tests that a corrupt artifact in the remote cache still results in a successful compile."""
        with self.temporary_workdir() as workdir, temporary_dir() as cachedir:
            with cache_server(cache_root=cachedir) as server:
                target = 'testprojects/tests/java/org/pantsbuild/testproject/matcher'
                config = {
                    'cache.compile.rsc': {
                        'write_to': [server.url],
                        'read_from': [server.url],
                    },
                }

                # Compile to populate the cache, and actually run the tests to help verify runtime.
                first_run = self.run_pants_with_workdir(['test', target],
                                                        workdir, config)
                self.assert_success(first_run)
                self.assertTrue("Compiling" in first_run.stdout_data)

                # Build again to hit the cache.
                second_run = self.run_pants_with_workdir(
                    ['clean-all', 'test', target], workdir, config)
                self.assert_success(second_run)
                self.assertFalse("Compiling" in second_run.stdout_data)

                # Corrupt the remote artifact.
                self.assertEqual(server.corrupt_artifacts(r'.*'), 1)

                # Ensure that the third run succeeds, despite a failed attempt to fetch.
                third_run = self.run_pants_with_workdir(
                    ['clean-all', 'test', target], workdir, config)
                self.assert_success(third_run)
                self.assertTrue("Compiling" in third_run.stdout_data)
  def test_java_compile_with_corrupt_remote(self):
    """Tests that a corrupt artifact in the remote cache still results in a successful compile."""
    with self.temporary_workdir() as workdir, temporary_dir() as cachedir:
      with cache_server(cache_root=cachedir) as server:
        target = 'testprojects/tests/java/org/pantsbuild/testproject/matcher'
        config = {
            'cache.compile.zinc': {
              'write_to': [server.url],
              'read_from': [server.url],
            },
        }

        # Compile to populate the cache, and actually run the tests to help verify runtime.
        first_run = self.run_pants_with_workdir(['test', target], workdir, config)
        self.assert_success(first_run)
        self.assertTrue("Compiling" in first_run.stdout_data)

        # Build again to hit the cache.
        second_run = self.run_pants_with_workdir(['clean-all', 'test', target], workdir, config)
        self.assert_success(second_run)
        self.assertFalse("Compiling" in second_run.stdout_data)

        # Corrupt the remote artifact.
        self.assertEqual(server.corrupt_artifacts(r'.*'), 1)

        # Ensure that the third run succeeds, despite a failed attempt to fetch.
        third_run = self.run_pants_with_workdir(['clean-all', 'test', target], workdir, config)
        self.assert_success(third_run)
        self.assertTrue("Compiling" in third_run.stdout_data)
示例#3
0
 def setup_server(self, return_failed=False, cache_root=None):
     with cache_server(return_failed=return_failed,
                       cache_root=cache_root) as server:
         yield server
 def setup_server(self, return_failed=False, cache_root=None):
   with cache_server(return_failed=return_failed, cache_root=cache_root) as server:
     yield server