Gets the TeX summary files for each test.

    :param dirnames: the list of directories to merge data from.

    :type dirnames: list

    :returns: a list of summary file names.
    :rtype: list

def get_summary_files(dirnames):
    """Gets the TeX summary files for each test.

    :param dirnames: the list of directories to merge data from.

    :type dirnames: list

    :returns: a list of summary file names.
    :rtype: list

    """
    # A useful regular expression to get step number in the current directory
    step_nb_re = re.compile(r"^([0-9]+)_\S+")

    # The final list of summary files
    final_summary_files = []

    # For each of the directory
    for dn in dirnames:
        # Getting the step directories
        step_dir = [
            n for n in os.listdir(dn)
            if os.path.isdir(os.path.join(dn, n)) and step_nb_re.match(n)
        ]

        # Sorting the step directories
        step_dir.sort(key=lambda x: int(step_nb_re.match(x).group(1)))

        # Getting the name of the summary file for each of the step directory
        step_summary_files = [
            glob(os.path.join(dn, sn, "*.summary.tex")) for sn in step_dir
        ]

        # Checking we have only one summary file
        for summary_file in step_summary_files:
            if len(summary_file) > 1:
                raise ProgramError("{}: multiple summary files".format(
                    os.path.join(dn, sn),
                ))

            if not summary_file:
                raise ProgramError("{}: missing summary file".format(
                    os.apth.join(dn, sn),
                ))

        final_summary_files.extend(i[0] for i in step_summary_files)

    return [os.path.abspath(fn) for fn in final_summary_files]