Exemple #1
0
    def migrate_results_trees(self, expected_results, confirmed_results):
        cwd = os.getcwd()
        expected_results = moresh.relative_path(expected_results, cwd)
        confirmed_results = moresh.relative_path(confirmed_results, cwd)
        
        # Files are listed in 'topdown' order.
        logging.debug("Migrating %s to %s"%(confirmed_results,expected_results))
        common_files, unique_to_expected, unique_to_confirmed =\
            moresh.compare_trees(expected_results, confirmed_results, ["\.svn"])

        # Overwritten results
        for expected_filepath, confirmed_filepath in common_files:
            mv_cmd = 'mv -f %s %s'%(confirmed_filepath, expected_filepath)
            logging.debug(mv_cmd)
            os.system(mv_cmd)
        
        # Old expected results to be removed
        for expected_filepath in unique_to_expected:
            logging.debug("recursive_remove %s --force"%expected_filepath)
            version_control.recursive_remove(expected_filepath, '--force')

        # New expected results to be added
        for confirmed_filepath in unique_to_confirmed:
            expected_filepath = confirmed_filepath.replace('.confirmed', '')
            assert not os.path.exists(expected_filepath)

            if os.path.isdir(confirmed_filepath) \
               and moresh.is_recursively_empty(confirmed_filepath):
                continue # Do not add empty directory to version control.
            
            rename_cmd = 'os.rename("%s", "%s")'%(confirmed_filepath, expected_filepath)
            logging.debug(rename_cmd)
            eval(rename_cmd)

            version_control.recursive_add(expected_filepath)
Exemple #2
0
    def __init__(self, targets, options):
        super(confirm, self).__init__(targets, options)

        # Trying to isolate a weard bug in confirm...
        true_level = logging.root.level
        logging.root.removeHandler(core.hdlr)

        import StringIO
        strstream = StringIO.StringIO()
        hdlr = logging.StreamHandler(strstream)
        logging.root.addHandler(hdlr)
        logging.root.setLevel(logging._levelNames["DEBUG"])
        ###

        for (family, test_list) in Test._families_map.iteritems():
            os.chdir(family)

            config_path = config_file_path()
            try:
                version_control.add(config_path)
                version_control.add(ppath.pytest_dir)
                version_control.ignore(ppath.pytest_dir, ['*.compilation_log'])
                for test in test_list:
                    if test.disabled:
                        continue
                    svn_results = test.resultsDirectory(tests.SVN_RESULTS)

                    if os.path.exists(svn_results):
                        expected_results = test.resultsDirectory(
                            tests.EXPECTED_RESULTS)
                        confirmed_results = expected_results + '.confirmed'
                        if os.path.exists(confirmed_results):
                            shutil.rmtree(
                                confirmed_results)  #in case we crashed
                        os.rename(expected_results, confirmed_results)
                        os.rename(svn_results, expected_results)
                        self.migrate_results_trees(expected_results,
                                                   confirmed_results)
                        shutil.rmtree(confirmed_results)
                    else:
                        version_control.add(test.resultsDirectory())
                        version_control.recursive_add(
                            test.resultsDirectory(tests.EXPECTED_RESULTS))
                        version_control.ignore(
                            test.resultsDirectory(),
                            ['.plearn', tests.RUN_RESULTS, 'PSAVEDIFF'])

            except version_control.VersionControlError:
                raise core.PyTestUsageError(
                    "The directory in which lies a config file must be added to version control by user.\n"
                    "%s was not." % family)

        # ... trying to isolate a weard bug in confirm
        logging.root.removeHandler(hdlr)
        #core.mail("PyTest Confirm Log", strstream.getvalue())

        logging.root.addHandler(core.hdlr)
Exemple #3
0
    def __init__( self, targets, options ):
        super(confirm, self).__init__(targets, options)

        # Trying to isolate a weard bug in confirm...        
        true_level = logging.root.level
        logging.root.removeHandler(core.hdlr)

        import StringIO
        strstream = StringIO.StringIO()
        hdlr      = logging.StreamHandler(strstream)        
        logging.root.addHandler(hdlr)
        logging.root.setLevel(logging._levelNames["DEBUG"])
        ###
        
        for (family, test_list) in Test._families_map.iteritems():
            os.chdir( family )

            config_path = config_file_path()
            try:
                version_control.add( config_path )
                version_control.add( ppath.pytest_dir )
                version_control.ignore( ppath.pytest_dir, [ '*.compilation_log' ] )
                for test in test_list:
                    if test.disabled:
                        continue
                    svn_results = test.resultsDirectory(tests.SVN_RESULTS)

                    if os.path.exists(svn_results):
                        expected_results = test.resultsDirectory(tests.EXPECTED_RESULTS)
                        confirmed_results = expected_results+'.confirmed'
                        if os.path.exists(confirmed_results):
                            shutil.rmtree(confirmed_results)#in case we crashed
                        os.rename(expected_results, confirmed_results)
                        os.rename(svn_results, expected_results)
                        self.migrate_results_trees(expected_results, confirmed_results)
                        shutil.rmtree(confirmed_results)
                    else:
                        version_control.add( test.resultsDirectory() )
                        version_control.recursive_add( test.resultsDirectory(tests.EXPECTED_RESULTS) )
                        version_control.ignore( test.resultsDirectory(), [ '.plearn', tests.RUN_RESULTS, 'PSAVEDIFF' ] )

            except version_control.VersionControlError:
                raise core.PyTestUsageError(
                    "The directory in which lies a config file must be added to version control by user.\n"
                    "%s was not." % family
                    )

        # ... trying to isolate a weard bug in confirm
        logging.root.removeHandler(hdlr)
        #core.mail("PyTest Confirm Log", strstream.getvalue())

        logging.root.addHandler(core.hdlr)
Exemple #4
0
    def migrate_results_trees(self, expected_results, confirmed_results):
        cwd = os.getcwd()
        expected_results = moresh.relative_path(expected_results, cwd)
        confirmed_results = moresh.relative_path(confirmed_results, cwd)

        # Files are listed in 'topdown' order.
        logging.debug("Migrating %s to %s" %
                      (confirmed_results, expected_results))
        common_files, unique_to_expected, unique_to_confirmed =\
            moresh.compare_trees(expected_results, confirmed_results, ["\.svn"])

        # Overwritten results
        for expected_filepath, confirmed_filepath in common_files:
            mv_cmd = 'mv -f %s %s' % (confirmed_filepath, expected_filepath)
            logging.debug(mv_cmd)
            os.system(mv_cmd)

        # Old expected results to be removed
        for expected_filepath in unique_to_expected:
            logging.debug("recursive_remove %s --force" % expected_filepath)
            version_control.recursive_remove(expected_filepath, '--force')

        # New expected results to be added
        for confirmed_filepath in unique_to_confirmed:
            expected_filepath = confirmed_filepath.replace('.confirmed', '')
            assert not os.path.exists(expected_filepath)

            if os.path.isdir(confirmed_filepath) \
               and moresh.is_recursively_empty(confirmed_filepath):
                continue  # Do not add empty directory to version control.

            rename_cmd = 'os.rename("%s", "%s")' % (confirmed_filepath,
                                                    expected_filepath)
            logging.debug(rename_cmd)
            eval(rename_cmd)

            version_control.recursive_add(expected_filepath)