Esempio n. 1
0
    def test_crc_is_stored_properly(self):
        self._add_to_db('o1', 'i2', compute_crc=True)

        self._change_mtime('i2')
        self._change_size('o1')
        actual = self._changed_files('o1', 'i2', compute_crc=True)
        expected = set(['o1'])
        self.assertEqual(expected, actual)
        filemod_db.set_up_to_date('o1')

        # Even though we changed mtime, we're ok because the crc is stored.
        self._change_mtime('o1')
        actual = self._changed_files('o1', 'i2', compute_crc=True)
        self.assertEqual(set(), actual)

        # This is true even if we get rid of caches, and fall back on the db.
        filemod_db.reset_for_tests()
        actual = self._changed_files('o1', 'i2', compute_crc=True)
        self.assertEqual(set(), actual)

        # Again, if we don't include compute_crc, the test fails.
        filemod_db.reset_for_tests()
        actual = self._changed_files('o1', 'i2')
        expected = set(['o1'])
        self.assertEqual(expected, actual)
Esempio n. 2
0
 def test_force_flag_present(self):
     # When we call changed_files with force=True, and it says
     # nothing has changed, it's ok to then call set_up_to_date().
     self._add_to_db('o1', 'i1')
     actual = self._changed_files('o1', 'i1', force=True)
     self.assertEqual(set(['o1']), actual)
     filemod_db.set_up_to_date('o1')
Esempio n. 3
0
 def _add_to_db(self, outfile_name, *infile_names, **kwargs):
     """Adds info about outfile_name and infile_names to filemod-db."""
     _ = self._changed_files(outfile_name, *infile_names, **kwargs)
     self._create_files([outfile_name])     # because it's 'changed'!
     filemod_db.set_up_to_date(outfile_name)
     # Now we'll simulate restarting the server, so all state in
     # filemod_db gets erased.
     filemod_db.sync()
     filemod_db.reset_for_tests()
Esempio n. 4
0
    def test_outfile_does_not_exist(self):
        # Create the test-db
        self._add_to_db('o1', 'i1', 'i2')
        # We should say o0 has changed, since it doesn't exist.
        actual = self._changed_files('o0', 'i1', 'i2')
        expected = set(['o0'])
        self.assertEqual(expected, actual)
        filemod_db.set_up_to_date('o0')

        # We should still say it's changed, even though there's now
        # old filemod-db info (in particular, a negative cache entry).
        actual = self._changed_files('o0', 'i1', 'i2')
        expected = set(['o0'])
        self.assertEqual(expected, actual)
Esempio n. 5
0
    def test_changed_files_destroys_symlinks(self):
        self._add_to_db('o1', 'i2', 'i3')

        self.assertEqual(set(['o_link']),
                         filemod_db.changed_files('o_link', 'i2', 'i3',
                                                  context='test'))
        os.symlink('o1', self._abspath('o_link'))
        self.assertTrue(os.path.islink(self._abspath('o_link')))
        self.assertTrue(os.path.samefile(self._abspath('o1'),
                                         self._abspath('o_link')))
        filemod_db.set_up_to_date('o_link')

        self._change_mtime('i2')
        del filemod_db._CURRENT_FILE_INFO['i2']
        actual = self._changed_files('o_link', 'i2', 'i3')
        self.assertEqual(set(['i2']), actual)
        filemod_db.set_up_to_date('o_link')
        self.assertFalse(os.path.islink(self._abspath('o_link')))
Esempio n. 6
0
    def test_changed_outfile_as_infile(self):
        """Test when the outfile for one process is the infile for the next."""
        self._add_to_db('o1', 'i1')
        self._add_to_db('o2', 'o1')

        # Now we're going to change 'o1', and it should tell us that
        # 'o2' needs to change.  Before changing 'o1' though, 'o2' is
        # happy:
        self.assertEqual(set(), self._changed_files('o2', 'o1'))

        self._changed_files('o1', 'i1', force=True)
        with open(self._abspath('o1'), 'a') as f:
            f.write('changed!')
        filemod_db.set_up_to_date('o1')

        actual = self._changed_files('o2', 'o1')
        expected = set(['o1'])
        self.assertEqual(expected, actual)