Example #1
0
 def test_nothing_out_of_date_when_stampfile_does_exist(self, method):
     """Nothing marked out of date when stamp file doesn't exist."""
     job = MockJob()
     cwd = os.getcwd()
     jobstamp.run(job, 1, jobstamps_cache_output_directory=cwd, jobstamps_method=method)
     ret = jobstamp.out_of_date(job, 1, jobstamps_cache_output_directory=cwd, jobstamps_method=method)
     self.assertEqual(None, ret)
Example #2
0
    def test_dependency_out_of_date_when_dependency_updated(self, method):
        """Dependency is marked out of date when it is updated."""
        job = MockJob()
        dependency = os.path.join(os.getcwd(), "dependency")
        cwd = os.getcwd()
        with open(dependency, "w") as dependency_file:
            dependency_file.write("Contents")

        jobstamp.run(
            job, 1, jobstamps_dependencies=[dependency], jobstamps_cache_output_directory=cwd, jobstamps_method=method
        )

        time.sleep(1)

        with open(dependency, "w") as dependency_file:
            dependency_file.write("Updated")

        ret = jobstamp.out_of_date(
            MockJob(),
            1,
            jobstamps_dependencies=[dependency],
            jobstamps_cache_output_directory=cwd,
            jobstamps_method=method,
        )
        self.assertEqual(dependency, ret)
Example #3
0
    def test_output_file_out_of_date_when_output_file_doesnt_exist(self):
        """Output file is out of date when output file doesn't exist."""
        expected_outputs = os.path.join(os.getcwd(), "expected_output")
        cwd = os.getcwd()
        job = MockJob()

        jobstamp.run(job, 1, jobstamps_output_files=[expected_outputs], jobstamps_cache_output_directory=cwd)
        ret = jobstamp.out_of_date(
            job, 1, jobstamps_output_files=[expected_outputs], jobstamps_cache_output_directory=cwd
        )
        self.assertEqual(expected_outputs, ret)
Example #4
0
    def test_dependency_out_of_date_when_dependency_doesnt_exist(self, method):
        """Dependency is marked out of date when it does not exist."""
        job = MockJob()
        dependency = os.path.join(os.getcwd(), "dependency")
        cwd = os.getcwd()

        jobstamp.run(
            job, 1, jobstamps_dependencies=[dependency], jobstamps_cache_output_directory=cwd, jobstamps_method=method
        )
        ret = jobstamp.out_of_date(
            job, 1, jobstamps_dependencies=[dependency], jobstamps_cache_output_directory=cwd, jobstamps_method=method
        )
        self.assertEqual(dependency, ret)
def _any_would_run(func, filenames, *args):
    """True if a linter function would be called on any of filenames."""
    if os.environ.get("_POLYSQUARE_GENERIC_FILE_LINTER_NO_STAMPING", None):
        return True

    for filename in filenames:
        # suppress(E204)
        stamp_args, stamp_kwargs = _run_lint_on_file_stamped_args(filename,
                                                                  *args,
                                                                  **{})
        dependency = jobstamp.out_of_date(func,
                                          *stamp_args,
                                          **stamp_kwargs)

        if dependency:
            return True

    return False
Example #6
0
 def test_stampfile_out_of_date_when_stampfile_doesnt_exist(self, method):
     """Stamp file marked out of date when stamp file doesn't exist."""
     cwd = os.getcwd()
     ret = jobstamp.out_of_date(MockJob(), 1, jobstamps_cache_output_directory=cwd, jobstamps_method=method)
     self.assertNotEqual(None, ret)