def test_aig_file_vs_blame_degrees_table(self) -> None:
        """
        Tests the latex booktabs format for the file vs.

        ci table.
        """
        vara_cfg()["paper_config"][
            "current_config"] = "test_diff_correlation_overview_table"
        initialize_projects()
        load_paper_config()

        # latex booktabs is default format
        table_str = AuthorBlameVsFileDegreesTable(
            TableConfig.from_kwargs(view=False),
            case_study=get_loaded_paper_config().get_case_studies(
                "xz")[0]).tabulate(TableFormat.LATEX_BOOKTABS, False)

        self.assertEqual(
            r"""\begin{tabular}{lrrrrr}
\toprule
{} &  blame\_num\_commits &  blame\_node\_degree &  author\_diff &  file\_num\_commits &  file\_node\_degree \\
author         &                    &                    &              &                   &                   \\
\midrule
Alexey Tourbin &                NaN &                NaN &          NaN &                 1 &                 2 \\
Ben Boeckel    &                NaN &                NaN &          NaN &                 1 &                 2 \\
Jim Meyering   &                NaN &                NaN &          NaN &                 1 &                 2 \\
Lasse Collin   &              124.0 &                0.0 &          0.0 &               479 &                 6 \\
\bottomrule
\end{tabular}
""", table_str)
    def test_table_tex_output(self) -> None:
        """Check whether the table produces the correct tex output."""
        vara_cfg()["paper_config"][
            "current_config"] = "test_diff_correlation_overview_table"
        initialize_projects()
        load_paper_config()
        table = diff_correlation_overview_table.DiffCorrelationOverviewTable(
            TableConfig.from_kwargs(view=False)).tabulate(
                TableFormat.LATEX_BOOKTABS, False)

        with open("tables/b_diff_correlation_overview.tex") as expected:
            self.assertEqual(table, expected.read())
Example #3
0
def main(context: click.Context, **kwargs: tp.Any) -> None:
    """Entry point for the table generation tool."""
    # store common options in context so they can be passed to subcommands
    common_options = CommonTableOptions.from_kwargs(**kwargs)
    table_config = TableConfig.from_kwargs(**kwargs)
    context.ensure_object(dict)
    context.obj["common_options"] = common_options
    context.obj["table_config"] = table_config
    context.obj["save_artefact"] = kwargs["save_artefact"]

    initialize_cli_tool()
    initialize_projects()
    initialize_tables()
    initialize_plots()
    def test_one_case_study_latex_booktabs(self) -> None:
        """"Tests the latex booktabs format for the cs overview table."""
        vara_cfg()["paper_config"]["current_config"] = "test_revision_lookup"
        initialize_projects()
        load_paper_config()

        # latex booktabs is default format
        table_str = CaseStudyMetricsTable(TableConfig.from_kwargs(
            view=False)).tabulate(TableFormat.LATEX_BOOKTABS, False)

        self.assertEqual(
            r"""\begin{tabular}{llrrrl}
\toprule
{} &       Domain &    LOC &  Commits &  Authors &    Revision \\
\midrule
\textbf{brotli} &  Compression &  34639 &      848 &       40 &  aaa4424d9b \\
\bottomrule
\end{tabular}
""", table_str)
Example #5
0
    def test_basic_repo_latex_booktabs(self) -> None:
        """"Tests the latex booktabs format of the basic bug detection test
        repo."""

        # latex booktabs is default format
        table = BugOverviewTable(TableConfig.from_kwargs(view=False),
                                 case_study=CaseStudy(
                                     BasicBugDetectionTestRepo.NAME, 1))

        # each bug must be matched separately since order is unclear
        result_bug_regex =\
            re.compile(
                       r"&\s*3b76c8d295385358375fefdb0cf045d97ad2d193\s*"
                       r"&\s*Multiplication result fix\\textbackslash n \s*"
                       r"&\s*VaRA Tester\s*"
                       r"&\s*None\s*\\\\\s*", re.DOTALL)
        type_bug_regex = \
            re.compile(r"&\s*2da78b2820370f6759e9086fad74155d6655e93b\s*"
                       r"&\s*Fixes return type of multiply\\textbackslash n \s*"
                       r"&\s*VaRA Tester\s*"
                       r"&\s*None\s*\\\\\s*", re.DOTALL)
        string_bug_regex = \
            re.compile(r"&\s*d846bdbe45e4d64a34115f5285079e1b5f84007f\s*"
                       r"&\s*Fixes answer to everything\\textbackslash n \s*"
                       r"&\s*VaRA Tester\s*"
                       r"&\s*None\s*\\\\\s*", re.DOTALL)
        arg_bug_regex = \
            re.compile(r"&\s*ddf0ba95408dc5508504c84e6616c49128410389\s*"
                       r"&\s*Fixed function arguments\\textbackslash n \s*"
                       r"&\s*VaRA Tester\s*"
                       r"&\s*None\s*\\\\.*", re.DOTALL)

        table_string = table.tabulate(TableFormat.LATEX_BOOKTABS, False)

        result_match = re.search(result_bug_regex, table_string)
        type_match = re.search(type_bug_regex, table_string)
        string_match = re.search(string_bug_regex, table_string)
        arg_match = re.search(arg_bug_regex, table_string)

        self.assertIsNotNone(result_match)
        self.assertIsNotNone(type_match)
        self.assertIsNotNone(string_match)
        self.assertIsNotNone(arg_match)
    def test_multiple_case_studies_latex_booktabs(self) -> None:
        """"Tests the latex booktabs format for the cs overview table."""
        vara_cfg()["paper_config"]["current_config"] = "test_artefacts_driver"
        initialize_projects()
        load_paper_config()

        # latex booktabs is default format
        table_str = CaseStudyMetricsTable(TableConfig.from_kwargs(
            view=False)).tabulate(TableFormat.LATEX_BOOKTABS, False)

        self.assertEqual(
            r"""\begin{tabular}{llrrrl}
\toprule
{} &                Domain &    LOC &  Commits &  Authors &    Revision \\
\midrule
\textbf{gravity} &  Programming language &  22923 &      663 &       39 &  2c71dec8ad \\
\textbf{xz     } &           Compression &  37021 &     1143 &       16 &  c5c7ceb08a \\
\bottomrule
\end{tabular}
""", table_str)
    def test_caig_metrics_table(self) -> None:
        """Tests the latex booktabs format for the caig metrics table."""
        vara_cfg()["paper_config"][
            "current_config"] = "test_diff_correlation_overview_table"
        initialize_projects()
        load_paper_config()

        # latex booktabs is default format
        table_str = CommitAuthorInteractionGraphMetricsTable(
            TableConfig.from_kwargs(view=False),
            case_study=get_loaded_paper_config().get_all_case_studies(
            )).tabulate(TableFormat.LATEX_BOOKTABS, False)

        self.assertEqual(
            r"""\begin{tabular}{lrrrrrrrrrrrrrr}
\toprule
{} & commits & authors & nodes & edges & \multicolumn{4}{c}{node degree} & \multicolumn{3}{c}{node out degree} & \multicolumn{3}{c}{node in degree} \\
{} &        mean & median & min & max &          median & min & max &         median & min & max \\
\midrule
\textbf{xz} &    1143 &      28 &   125 &    92 &        1.47 &    1.0 &   0 &  92 &             1.0 &   0 &   1 &            0.0 &   0 &  92 \\
\bottomrule
\end{tabular}
""", table_str)
    def test_one_case_study_latex_booktabs(self) -> None:
        """Tests the latex booktabs format for the code centrality metrics
        table."""
        vara_cfg()["paper_config"][
            "current_config"] = "test_diff_correlation_overview_table"
        initialize_projects()
        load_paper_config()

        # latex booktabs is default format
        table_str = TopCentralCodeCommitsTable(
            TableConfig.from_kwargs(view=False),
            case_study=get_loaded_paper_config().get_case_studies("xz")[0],
            num_commits=10).tabulate(TableFormat.LATEX_BOOKTABS, False)

        self.assertEqual(
            r"""\begin{table}
\centering
\caption{Top 10 Central Code Commits}
\begin{tabular}{lr}
\toprule
                                  commit &  centrality \\
\midrule
ef68dd4a92976276304de2aedfbe34ae91a86abb &          28 \\
57597d42ca1740ad506437be168d800a50f1a0ad &          16 \\
ea00545beace5b950f709ec21e46878e0f448678 &          16 \\
7f0a4c50f4a374c40acf4b86848f301ad1e82d34 &          15 \\
c15c42abb3c8c6e77c778ef06c97a4a10b8b5d00 &          15 \\
fa3ab0df8ae7a8a1ad55b52266dc0fd387458671 &          10 \\
1d924e584b146136989f48c13fff2632896efb3d &           9 \\
d8b41eedce486d400f701b757b7b5e4e32276618 &           8 \\
1b0ac0c53c761263e91e34195cb21dfdcfeac0bd &           6 \\
e0ea6737b03e83ccaff4514d00e31bb926f8f0f3 &           6 \\
\bottomrule
\end{tabular}
\end{table}
""", table_str)