Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'all' mutators group to avoid confusion with the experimental mutators #1008

Merged
merged 1 commit into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/generated/Mutators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ Operator Name Operator Semantics


Groups:
:all: cxx_all, experimental

:cxx_all: cxx_assignment, cxx_increment, cxx_decrement, cxx_arithmetic, cxx_comparison, cxx_boundary, cxx_bitwise, cxx_calls

:cxx_arithmetic: cxx_minus_to_noop, cxx_add_to_sub, cxx_sub_to_add, cxx_mul_to_div, cxx_div_to_mul, cxx_rem_to_div
Expand Down
31 changes: 17 additions & 14 deletions lib/Mutators/MutatorsFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ using namespace std;
static string Experimental() {
return "experimental";
}
static string AllMutatorsGroup() {
return "all";
}

static string CXX_Assignment() {
return "cxx_assignment";
Expand Down Expand Up @@ -69,14 +66,21 @@ static string CXX_Default() {
return "cxx_default";
}

static void expandGroups(const vector<string> &groups, const map<string, vector<string>> &mapping,
static void expandGroups(Diagnostics &diagnostics, const vector<string> &groups,
const map<string, vector<string>> &mapping,
unordered_set<string> &expandedGroups) {
for (const string &group : groups) {
if (mapping.count(group) == 0) {
expandedGroups.insert(group);
std::string tempGroup = group;
if (tempGroup == "all") {
diagnostics.warning(
"Group 'all' is replaced with 'cxx_all' and will be removed in a future release.");
tempGroup = "cxx_all";
}
if (mapping.count(tempGroup) == 0) {
expandedGroups.insert(tempGroup);
continue;
}
expandGroups(mapping.at(group), mapping, expandedGroups);
expandGroups(diagnostics, mapping.at(tempGroup), mapping, expandedGroups);
}
}

Expand Down Expand Up @@ -173,7 +177,6 @@ MutatorsFactory::MutatorsFactory(Diagnostics &diagnostics) : diagnostics(diagnos
groupsMapping[Experimental()] = { NegateConditionMutator::ID(),
ScalarValueMutator::ID(),
CXX_Logical() };
groupsMapping[AllMutatorsGroup()] = { CXX_All(), Experimental() };
}

template <typename MutatorClass>
Expand Down Expand Up @@ -252,13 +255,13 @@ MutatorsFactory::mutators(const vector<string> &groups,
std::unordered_set<std::string> expandedGroups;
std::unordered_set<std::string> expandedIgnoreGroups;
if (!ignoreGroups.empty()) {
expandGroups(ignoreGroups, groupsMapping, expandedIgnoreGroups);
expandGroups(diagnostics, ignoreGroups, groupsMapping, expandedIgnoreGroups);
}

if (groups.empty()) {
expandGroups({ CXX_Default() }, groupsMapping, expandedGroups);
expandGroups(diagnostics, { CXX_Default() }, groupsMapping, expandedGroups);
} else {
expandGroups(groups, groupsMapping, expandedGroups);
expandGroups(diagnostics, groups, groupsMapping, expandedGroups);
}

for (auto &ignoreGroup : expandedIgnoreGroups) {
Expand Down Expand Up @@ -309,10 +312,10 @@ std::vector<std::pair<std::string, std::string>> MutatorsFactory::commandLineOpt
}

std::unordered_set<std::string> mutatorsSet;
std::vector<std::string> groups({ AllMutatorsGroup() });
expandGroups({ AllMutatorsGroup() }, groupsMapping, mutatorsSet);
std::vector<std::string> groups({ CXX_All() });
expandGroups(diagnostics, { CXX_All() }, groupsMapping, mutatorsSet);

auto allMutators = mutators({ AllMutatorsGroup() }, {});
auto allMutators = mutators({ CXX_All() }, {});

for (auto &mutator : allMutators) {
options.emplace_back(mutator->getUniqueIdentifier(), mutator->getDescription());
Expand Down
5 changes: 0 additions & 5 deletions tests/MutatorsFactoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ TEST(MutatorsFactory, CompositeMutators) {
searchResult = find_if(mutators.begin(), mutators.end(), predicate("scalar_value_mutator"));
ASSERT_NE(searchResult, mutators.end());
}

{
mutators = factory.mutators({ "all" }, {});
ASSERT_EQ(mutators.size(), 45UL);
}
}

TEST(MutatorsFactory, UniqueMutators) {
Expand Down