Skip to content

Commit

Permalink
Merge branch 'vara-dev' of github.com:se-sic/VaRA-Tool-Suite into f-G…
Browse files Browse the repository at this point in the history
…enerateFeatureBlameReport
  • Loading branch information
Simon Rüdiger Steuer committed Jul 7, 2023
2 parents 2c56155 + 514c690 commit f3bf72b
Show file tree
Hide file tree
Showing 35 changed files with 1,152 additions and 202 deletions.
5 changes: 5 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
import cryptography.exceptions # isort:skip
import click # isort:skip
import git # isort:skip
import github # isort:skip
import urllib3.exceptions # isort:skip

# Some packages use new syntax for type checking that isn't available to us
import jwt.algorithms

import typing as tp # isort:skip

Expand Down
1 change: 1 addition & 0 deletions docs/source/vara-ts-api/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ creating plots, configuring the tool-suite itself and more.

tools/vara-pc
tools/vara-cs
tools/vara-cs-gui
tools/vara-run
tools/vara-plot
tools/vara-table
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/source/vara-ts-api/tools/vara-cs-gui.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
vara-cs-gui
===========

This gui tool provides functionality to create :ref:`case studies<Module: case_study>`.
Detailed information about how case studies work can be found :ref:`here<How to use case studies>`.

The gui is started by::

vara-cs-gui

The gui provides 3 Strategies to generate case studies:
- Manual revision selection: Select revision from the revision history of a project. Multiple revisions can be selected by holding `ctrl` and ranges by holding `shift`. Revisions which are blocked because of bugs in the compilation of the project are marked blue.
.. figure:: vara-cs-gui-manual.png

- Random Sampling: Sample a number of revisions using a random a Normal or HalfNormal Distribution.

.. figure:: vara-cs-gui-sample.png

- Sampling by Year: Sample a number of revisions per Year using a NormalDistribution.

.. figure:: vara-cs-gui-yearly.png

The command line tool :ref:`vara-cs gen<vara-cs gen>` provides additional functionality.
1 change: 1 addition & 0 deletions docs/source/vara-ts-api/tools/vara-cs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For more options, take a look at the command line parameters:
.. program-output:: vara-cs gen --help
:nostderr:

Also look at :ref:`vara-cs-gui<vara-cs-gui>`, which can be used to create case studies using a graphical interface.

vara-cs status
--------------
Expand Down
94 changes: 94 additions & 0 deletions tests/base/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
DummyConfiguration,
ConfigurationImpl,
ConfigurationOptionImpl,
FrozenConfiguration,
)


Expand Down Expand Up @@ -74,6 +75,66 @@ def test_to_str(self) -> None:

self.assertEqual(str(config), config.dump_to_string())

def test_equality_same(self) -> None:
"""Test to compare configuration to each other."""
config = ConfigurationImpl()
config.add_config_option(ConfigurationOptionImpl("foo", 42))
config_2 = ConfigurationImpl()
config_2.add_config_option(ConfigurationOptionImpl("foo", 42))

self.assertTrue(config == config_2)
self.assertFalse(config != config_2)

def test_equality_different(self) -> None:
"""Test to compare configuration to to each other."""
config = ConfigurationImpl()
config.add_config_option(ConfigurationOptionImpl("foo", 42))
config_2 = ConfigurationImpl()
config_2.add_config_option(ConfigurationOptionImpl("foo", False))

self.assertFalse(config == config_2)
self.assertTrue(config != config_2)

def test_equality_mapping(self) -> None:
"""Test to compare configuration to a mapping."""
config = ConfigurationImpl()
config.add_config_option(ConfigurationOptionImpl("foo", 42))

mapping_identical = {"foo": 42}
mapping_not_identical = {"foo": 43}
mapping_interpreted = {"foo": True}
mapping_not_interpreted = {"foo": False}

self.assertTrue(config == mapping_identical)
self.assertFalse(config != mapping_identical)

self.assertFalse(config == mapping_not_identical)
self.assertTrue(config != mapping_not_identical)

self.assertTrue(config == mapping_interpreted)
self.assertFalse(config != mapping_interpreted)

self.assertFalse(config == mapping_not_interpreted)
self.assertTrue(config != mapping_not_interpreted)

config_2 = ConfigurationImpl()
config_2.add_config_option(ConfigurationOptionImpl("foo", False))

self.assertFalse(config_2 == mapping_interpreted)
self.assertTrue(config_2 != mapping_interpreted)

self.assertTrue(config_2 == mapping_not_interpreted)
self.assertFalse(config_2 != mapping_not_interpreted)

def test_equality_othertypes(self) -> None:
"""Test to compare configuration to each other."""
config = ConfigurationImpl()
config.add_config_option(ConfigurationOptionImpl("foo", 42))
other_object = 42

self.assertFalse(config == other_object)
self.assertTrue(config != other_object)


class TestDummyConfiguration(unittest.TestCase):
"""Test if the Dummy Configuration does not allow any interface usage."""
Expand Down Expand Up @@ -106,3 +167,36 @@ def test_crash_dump_to_string(self) -> None:
with self.assertRaises(AssertionError):
d_config = DummyConfiguration()
d_config.dump_to_string()

def test_crash_freeze(self) -> None:
with self.assertRaises(AssertionError):
d_config = DummyConfiguration()
d_config.freeze()

def test_crash_unfreeze(self) -> None:
with self.assertRaises(AssertionError):
d_config = DummyConfiguration()
d_config.unfreeze()


class TestFrozenConfiguration(unittest.TestCase):
"""Test freeze and unfreeze methods of a FrozenConfiguration."""

def test_freeze_and_unfreeze(self) -> None:
config = ConfigurationImpl()
config.add_config_option(ConfigurationOptionImpl("foo", 42))
frozen_config = config.freeze()

self.assertTrue(isinstance(frozen_config, FrozenConfiguration))
self.assertTrue(frozen_config == config)
self.assertTrue(frozen_config is frozen_config.freeze())
self.assertFalse(frozen_config is config)

with self.assertRaises(NotImplementedError):
frozen_config.add_config_option(ConfigurationOptionImpl("foo", 42))

unfrozen_config = frozen_config.unfreeze()
self.assertTrue(isinstance(unfrozen_config, ConfigurationImpl))
self.assertTrue(unfrozen_config == config)
self.assertTrue(unfrozen_config is unfrozen_config.unfreeze())
self.assertFalse(unfrozen_config is frozen_config)
112 changes: 112 additions & 0 deletions tests/mapping/test_author_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import unittest

from varats.mapping.author_map import generate_author_map, Author, AuthorMap
from varats.projects.discover_projects import initialize_projects


class TestAuthor(unittest.TestCase):

def test_merge(self) -> None:
author_one = Author(1, "Jon Doe", "jon_doe@jon_doe.com")
author_two = Author(4, "J. Doe", "jon_doe@jon_doe.com")
author_three = Author(2, "Jon Doe", "[email protected]")
merge_one = author_one.merge(author_two)
self.assertEqual(merge_one.author_id, 1)
self.assertEqual(merge_one.names, {"Jon Doe", "J. Doe"})
self.assertEqual(merge_one.mail_addresses, {"jon_doe@jon_doe.com"})
merge_two = author_three.merge(author_one)
self.assertEqual(merge_two.author_id, 1)
self.assertEqual(merge_two.names, {"Jon Doe", "J. Doe"})
self.assertEqual(
merge_two.mail_addresses,
{"jon_doe@jon_doe.com", "[email protected]"}
)


class TestAuthorMap(unittest.TestCase):

def test_get_author_by_email(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
test_author = amap.get_author_by_email("[email protected]")
self.assertEqual(
test_author.mail_addresses,
{"[email protected]", "[email protected]"}
)
self.assertEqual(test_author.names, {"Jim Meyering"})

def test_get_author_by_name(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
test_author = amap.get_author_by_name("Jia Cheong Tan")
self.assertEqual(
test_author.names, {"Jia Cheong Tan", "Jia Tan", "jiat75"}
)
self.assertEqual(
test_author.mail_addresses,
{"[email protected]", "[email protected]"}
)

def test_get_author(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
test_author = amap.get_author("Jia Cheong Tan", "[email protected]")
self.assertEqual(
test_author.names, {"Jia Cheong Tan", "Jia Tan", "jiat75"}
)
self.assertEqual(
test_author.mail_addresses,
{"[email protected]", "[email protected]"}
)

def test_get_author_ambiguous(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
self.assertIsNone(amap.get_author("Jia Cheong Tan", "[email protected]"))

def test_get_author_missing_mail(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
self.assertIsNone(
amap.get_author("Jia Cheong Tan", "[email protected]")
)

def test_get_author_missing_name(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
self.assertIsNone(amap.get_author("Not Present", "[email protected]"))

def test_get_author_missing(self) -> None:
initialize_projects()
amap = generate_author_map("xz")
self.assertIsNone(amap.get_author("Not Present", "[email protected]"))

def test_author_merging(self) -> None:
amap = AuthorMap()
amap.add_entry("Jon Doe", "jon_doe@jon_doe.com")
amap.add_entry("JD", "[email protected]")
amap.add_entry("Jon Doe", "[email protected]")
disambiguated_author = amap.get_author("JD", "jon_doe@jon_doe.com")
self.assertEqual(disambiguated_author.author_id, 0)
self.assertEqual(disambiguated_author.names, {"Jon Doe", "JD"})
self.assertEqual(
disambiguated_author.mail_addresses,
{"jon_doe@jon_doe.com", "[email protected]"}
)

def test_author_merging_generate(self) -> None:
initialize_projects()
amap = generate_author_map("brotli")
test_author = amap.get_author("eustas", "[email protected]")
self.assertEqual(
test_author.names, {
"eustas", "Eugene Kliuchnikov", "Eugene Klyuchnikov",
"Evgenii Kliuchnikov"
}
)
self.assertEqual(
test_author.mail_addresses, {
"[email protected]", "[email protected]",
"[email protected]"
}
)
17 changes: 10 additions & 7 deletions tests/mapping/test_configuration_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ def test_inter_configs(self) -> None:
config_map.add_configuration(test_config_2)
config_map.add_configuration(test_config_3)

self.assertEqual(3, len(config_map.configurations()))
self.assertSetEqual({test_config_1, test_config_2, test_config_3},
set(config_map.configurations()))
configurations = config_map.configurations()
self.assertEqual(3, len(configurations))
self.assertIn(test_config_1, configurations)
self.assertIn(test_config_2, configurations)
self.assertIn(test_config_3, configurations)

def test_inter_id_config_tuples(self) -> None:
"""Test if we can iterate over all id configuration pairs."""
Expand All @@ -106,10 +108,11 @@ def test_inter_id_config_tuples(self) -> None:
config_map.add_configuration(test_config_2)
config_map.add_configuration(test_config_3)

self.assertEqual(3, len(config_map.id_config_tuples()))
self.assertSetEqual({(0, test_config_1), (1, test_config_2),
(2, test_config_3)},
set(config_map.id_config_tuples()))
id_config_tuples = config_map.id_config_tuples()
self.assertEqual(3, len(id_config_tuples))
self.assertIn((0, test_config_1), id_config_tuples)
self.assertIn((1, test_config_2), id_config_tuples)
self.assertIn((2, test_config_3), id_config_tuples)


class TestConfigurationMapStoreAndLoad(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/paper_mgmt/test_case_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ def test_extend_with_revs_per_year(self) -> None:
self.assertEqual(cs.num_stages, 17)
self.assertEqual(len(cs.revisions), 31)
self.assertEqual(
cs.revisions[0],
FullCommitHash("c563a4bc554a96bd0b6aab3c139715b7ec8f6ca3")
cs.get_stage_by_name('2022').revisions[0],
FullCommitHash("8fd225a2c149f30aeac377e68eb5abf6b28300ad")
)
self.assertEqual(
cs.revisions[-1],
Expand Down
2 changes: 1 addition & 1 deletion tests/table/test_case_study_metrics_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_one_case_study_latex_booktabs(self) -> None:
\toprule
& Domain & LOC (repo) & LOC (project) & Commits & Authors & Revision \\
\midrule
brotli & Compression & 34\,639 & 34\,639 & 848 & 40 & aaa4424d9b \\
brotli & Compression & 35\,662 & 35\,662 & 848 & 40 & aaa4424d9b \\
\bottomrule
\end{tabular}
""", table_str
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_git_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ def test_extensions_repr_gen(self):
c_style_config = ChurnConfig.create_c_style_languages_config()
self.assertEqual(
c_style_config.get_extensions_repr(),
["c", "cpp", "cxx", "h", "hpp", "hxx"]
["c", "cc", "cpp", "cxx", "h", "hpp", "hxx"]
)
self.assertEqual(
c_style_config.get_extensions_repr(prefix="*."),
["*.c", "*.cpp", "*.cxx", "*.h", "*.hpp", "*.hxx"]
["*.c", "*.cc", "*.cpp", "*.cxx", "*.h", "*.hpp", "*.hxx"]
)
self.assertEqual(
c_style_config.get_extensions_repr(suffix="|"),
["c|", "cpp|", "cxx|", "h|", "hpp|", "hxx|"]
["c|", "cc|", "cpp|", "cxx|", "h|", "hpp|", "hxx|"]
)


Expand Down
Loading

0 comments on commit f3bf72b

Please sign in to comment.