예제 #1
0
    def setUp(self):
        """
        Create a list of files separated in time so we can do dependency checking
        """
        import tempfile
        import time
        self.files = list()
        job_history = open_job_history(history_file)
        for i in range(6):
            #test_file =tempfile.NamedTemporaryFile(delete=False, prefix='testing_tmp')
            #self.files.append (test_file.name)
            # test_file.close()

            fh, temp_file_name = tempfile.mkstemp(suffix='.dot')
            self.files.append(temp_file_name)
            os.fdopen(fh, "w").close()

            # Save modify time in history file
            mtime = os.path.getmtime(temp_file_name)
            epoch_seconds = time.time()
            # Use epoch seconds unless there is a > 1 second discrepancy between system clock
            # and file system clock
            if epoch_seconds > mtime and epoch_seconds - mtime < 1.1:
                mtime = epoch_seconds
            else:
                # file system clock out of sync:
                #   Use file modify times: slow down in case of low counter resolution
                #       (e.g. old versions of NFS and windows)
                time.sleep(2)
            chksum = task.JobHistoryChecksum(
                temp_file_name, mtime, "", dummy_task())
            job_history[os.path.relpath(temp_file_name)] = chksum
예제 #2
0
    def setUp(self):
        """
        Create a list of files separated in time so we can do dependency checking
        """
        import tempfile
        import time
        self.files = list()
        job_history = open_job_history(history_file)
        for i in range(6):
            #test_file =tempfile.NamedTemporaryFile(delete=False, prefix='testing_tmp')
            #self.files.append (test_file.name)
            # test_file.close()

            fh, temp_file_name = tempfile.mkstemp(suffix='.dot')
            self.files.append(temp_file_name)
            os.fdopen(fh, "w").close()

            # Save modify time in history file
            mtime = os.path.getmtime(temp_file_name)
            epoch_seconds = time.time()
            # Use epoch seconds unless there is a > 1 second discrepancy between system clock
            # and file system clock
            if epoch_seconds > mtime and epoch_seconds - mtime < 1.1:
                mtime = epoch_seconds
            else:
                # file system clock out of sync:
                #   Use file modify times: slow down in case of low counter resolution
                #       (e.g. old versions of NFS and windows)
                time.sleep(2)
            chksum = task.JobHistoryChecksum(temp_file_name, mtime, "",
                                             dummy_task())
            job_history[os.path.relpath(temp_file_name)] = chksum
예제 #3
0
    def test_up_to_date(self):
        #
        #   lists of files
        #
        self.assertTrue(not task.needs_update_check_modify_time(self.files[0:2],
                                                                self.files[2:6],
                                                                job_history=open_job_history(
                                                                    history_file),
                                                                task=dummy_task())[0])
        self.assertTrue(task.needs_update_check_modify_time(self.files[2:6],
                                                            self.files[0:2],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])
        #
        #   singletons and lists of files
        #
        self.assertTrue(not task.needs_update_check_modify_time(self.files[0],
                                                                self.files[2:6],
                                                                job_history=open_job_history(
                                                                    history_file),
                                                                task=dummy_task())[0])
        self.assertTrue(task.needs_update_check_modify_time(self.files[2:6],
                                                            self.files[0],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        #
        #   singletons
        #
        self.assertTrue(task.needs_update_check_modify_time(self.files[3],
                                                            self.files[0],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        # self -self = no update
        self.assertTrue(not task.needs_update_check_modify_time(self.files[0],
                                                                self.files[0],
                                                                job_history=open_job_history(
                                                                    history_file),
                                                                task=dummy_task())[0])

        #
        #   missing files means need update
        #
        self.assertTrue(task.needs_update_check_modify_time(self.files[0:2] +
                                                            ["uncreated"],
                                                            self.files[3:6],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        self.assertTrue(task.needs_update_check_modify_time(self.files[0:2],
                                                            self.files[3:6] +
                                                            ["uncreated"],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        #
        #   None means need update
        #
        self.assertTrue(task.needs_update_check_modify_time(self.files[0:2],
                                                            None,
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        #
        #   None input means need update only if do not exist
        #
        self.assertTrue(not task.needs_update_check_modify_time(None,
                                                                self.files[3:6],
                                                                job_history=open_job_history(
                                                                    history_file),
                                                                task=dummy_task())[0])

        #
        #   None + missing file means need update
        #
        self.assertTrue(task.needs_update_check_modify_time(self.files[0:2] +
                                                            ["uncreated"],
                                                            None,
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])

        self.assertTrue(task.needs_update_check_modify_time(None,
                                                            self.files[3:6] +
                                                            ["uncreated"],
                                                            job_history=open_job_history(
                                                                history_file),
                                                            task=dummy_task())[0])
예제 #4
0
    def test_up_to_date(self):
        #
        #   lists of files
        #
        self.assertTrue(not task.needs_update_check_modify_time(
            self.files[0:2],
            self.files[2:6],
            job_history=open_job_history(history_file),
            task=dummy_task())[0])
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[2:6],
                self.files[0:2],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])
        #
        #   singletons and lists of files
        #
        self.assertTrue(not task.needs_update_check_modify_time(
            self.files[0],
            self.files[2:6],
            job_history=open_job_history(history_file),
            task=dummy_task())[0])
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[2:6],
                self.files[0],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        #
        #   singletons
        #
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[3],
                self.files[0],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        # self -self = no update
        self.assertTrue(not task.needs_update_check_modify_time(
            self.files[0],
            self.files[0],
            job_history=open_job_history(history_file),
            task=dummy_task())[0])

        #
        #   missing files means need update
        #
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[0:2] + ["uncreated"],
                self.files[3:6],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[0:2],
                self.files[3:6] + ["uncreated"],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        #
        #   None means need update
        #
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[0:2],
                None,
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        #
        #   None input means need update only if do not exist
        #
        self.assertTrue(not task.needs_update_check_modify_time(
            None,
            self.files[3:6],
            job_history=open_job_history(history_file),
            task=dummy_task())[0])

        #
        #   None + missing file means need update
        #
        self.assertTrue(
            task.needs_update_check_modify_time(
                self.files[0:2] + ["uncreated"],
                None,
                job_history=open_job_history(history_file),
                task=dummy_task())[0])

        self.assertTrue(
            task.needs_update_check_modify_time(
                None,
                self.files[3:6] + ["uncreated"],
                job_history=open_job_history(history_file),
                task=dummy_task())[0])