def analyze(file_path, pattern_reg_exp):
    """ Return the set of passing and failing methods and a map
        from failing methods to the reason they failed.
    """
    #
    # We pass in the pattern regular expression so we will not have
    # compile it repeatedly. For reference, here is its definition:
    #
    # r'^(Successfully read (.*))|(Failed to read (.*)\[(.*)\])$'
    #
    passing, failing, fail_reason_map = set(), set(), {}
    with open(file_path, 'r') as file:
        # passing and failing track the set of methods that were
        # successfully compiled and unsuccessfully compiled as reported by this file.
        for line in file:
            m = pattern_reg_exp.match(line)
            if m:
                if m.group(1):
                    passing.add(m.group(2))
                else:
                    method = m.group(4)
                    failing.add(method)
                    reason = m.group(5)
                    fail_reason_map[method] = reason
    return passing, failing, fail_reason_map