def test_total_set(self):
        print("\nInformation about total set", end="")

        a = ProjectStatus(f'logs{os.sep}core@dune-common{os.sep}dune@total')

        print(tabulate(a.get_summary(), headers='keys', tablefmt='psql', showindex=False))

        self.assertTrue(True)
    def test_variants(self):
        de = DataExtraction(f'logs{os.sep}core@dune-common', 'dune')
        variants = de.get_variants()

        summary_cols = ["Name", "Period", "Builds",
                        "Faults", "Tests",
                        "Duration", "Interval"]

        df = pd.DataFrame(columns=summary_cols)

        a = ProjectStatus(f'')

        for variant in variants:
            variant = variant.replace('/', '-')
            variant = variant.translate({ord(c): "_" for c in "!#$%^&*()[]{};:,.<>?|`~=+"})

            a.update_project(f'logs{os.sep}core@dune-common{os.sep}dune@{variant}')
            df = df.append(a.get_summary())

        print(tabulate(df, headers='keys', tablefmt='psql', showindex=False))

        self.assertTrue(True)
    def test_plot_heatmap_total(self):
        path = f'logs{os.sep}core@dune-common{os.sep}dune@total'
        a = ProjectStatus(path)

        fig, ax = plt.subplots(figsize=(30, 20))
        a.visualize_dataset_heatmap(fig, ax)
        plt.savefig(os.path.join(path, "heatpmap.pdf"), bbox_inches='tight')

        fig, ax = plt.subplots(figsize=(15, 10))
        a.visualize_dataset_info(ax)
        plt.savefig(os.path.join(path, "failures_by_cycle.pdf"), bbox_inches='tight')
        plt.clf()

        fig, ax = plt.subplots(figsize=(15, 10))
        a.visualize_testcase_volatility(ax)
        plt.savefig(os.path.join(path, "testcase_volatility.pdf"), bbox_inches='tight')
        plt.clf()

        self.assertTrue(True)
    def test_plot_heatmap_variants(self):
        de = DataExtraction(f'logs{os.sep}core@dune-common')
        variants = sorted(de.get_variants())

        for variant in variants:
            variant = variant.replace('/', '-')
            path = f'logs{os.sep}core@dune-common{os.sep}dune@{variant}'
            a = ProjectStatus(path)

            fig, ax = plt.subplots(figsize=(30, 20))
            a.visualize_dataset_heatmap(fig, ax)
            plt.savefig(os.path.join(path, "heatpmap.pdf"), bbox_inches='tight')

            fig, ax = plt.subplots(figsize=(15, 10))
            a.visualize_dataset_info(ax)
            plt.savefig(os.path.join(path, "failures_by_cycle.pdf"), bbox_inches='tight')
            plt.clf()

            fig, ax = plt.subplots(figsize=(15, 10))
            a.visualize_testcase_volatility(ax)
            plt.savefig(os.path.join(path, "testcase_volatility.pdf"), bbox_inches='tight')
            plt.clf()

        self.assertTrue(True)
def plot_project_status(project_stat: ProjectStatus, path):
    fig, ax = plt.subplots(figsize=(30, 20))
    project_stat.visualize_dataset_heatmap(fig, ax)
    plt.savefig(os.path.join(path, "heatpmap.pdf"), bbox_inches='tight')
    plt.close(fig)

    fig, ax = plt.subplots(figsize=(15, 10))
    project_stat.visualize_dataset_info(ax)
    plt.savefig(os.path.join(path, "failures_by_cycle.pdf"),
                bbox_inches='tight')
    plt.close(fig)

    fig, ax = plt.subplots(figsize=(15, 10))
    project_stat.visualize_testcase_volatility(ax)
    plt.savefig(os.path.join(path, "testcase_volatility.pdf"),
                bbox_inches='tight')
    plt.close(fig)
    def test_both(self):
        print("\n")
        de = DataExtraction(f'logs{os.sep}core@dune-common')
        variants = sorted(de.get_variants())

        summary_cols = ["Name", "Period", "Builds",
                        "Faults", "Tests",
                        "Duration", "Interval"]

        df = pd.DataFrame(columns=summary_cols)

        a = ProjectStatus(f'logs{os.sep}core@dune-common{os.sep}dune@total')

        df = df.append(a.get_summary())

        for variant in variants:
            variant = variant.replace('/', '-')
            a.update_project(f'logs{os.sep}core@dune-common{os.sep}dune@{variant}')
            df = df.append(a.get_summary())

        print(tabulate(df, headers='keys', tablefmt='psql', showindex=False))
        print(df.to_latex(index=False))

        self.assertTrue(True)
    def test_main_system(self):
        a = ProjectStatus(f'logs{os.sep}core@dune-common')

        print(tabulate(a.get_summary(), headers='keys', tablefmt='psql', showindex=False))

        self.assertTrue(True)
    data_extr = DataExtraction(args.log_dir, args.project_name)
    variants = data_extr.get_variants()

    with alive_bar(len(variants) + 2, title="Project Status") as bar:
        # Get the general status from project
        #bar.text('Processing the general status from project...')
        #bar()
        #project_stat = ProjectStatus(args.log_dir)
        #df = df.append(project_stat.get_summary())

        # Get the project status from total set
        bar.text('Processing the project status from total set...')
        bar()
        path = f"{args.log_dir}{os.sep}{args.project_name}@total"
        project_stat = ProjectStatus(path)
        df = df.append(project_stat.get_summary())
        plot_project_status(project_stat, path)

        # Get the status for each variant from project
        bar.text('Processing the project status for each variant...')
        bar()
        for variant in variants:
            variant = variant.replace('/', '-')
            path = f"{args.log_dir}{os.sep}{args.project_name}@{variant}"

            project_stat.update_project(path)
            df = df.append(project_stat.get_summary())
            plot_project_status(project_stat, path)

            bar()