approvals / approvals/ApprovalTests.cpp

Data Driven Model for Merge Tools

Open
#105 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement on_hold reporters
Dominant language
C++
Stars
339
Forks
55
PR merge metrics
No merged PRs in 30d

Description

This is just an idea to make adding new merge tools simpler. A lot of the merge tools function quite similarly and their implementations in ApprovalTests each require the creation of at least on class per merge tool. However, given multiple versions, names, or operating systems, the number of classes required increases. This amounts to quite a bit of boilerplate when adding new merge tools. By defining a struct for storing all of the necessary data, construction of one-off classes can be avoided, and this struct can provide all of the necessary details required to find and call a diff tool from within ApprovalTests.

An example struct as follows hopefully encapsulates most of the variance between merge tools.

#include <string>
#include <vector>

enum Context {
  Background = 0;
  Foreground
};

struct DiffTool {
  std::string name;
  std::vector<std::string> search_paths;
  std::vector<std::string> names;
  std::string arguments;
  Context = Context::Background;
  unsigned int priority = 0;
};

By defining a standard search procedure for the search_paths and names, each tool can be found using the same process. The search_paths and names members would likely need to be defined in a way to only include certain values dependent on the OS.

I'm not sure how viable this is, but I wanted to get the idea out there. It would be nice to only have to define most merge tools in one place.

Note: Multiple versions of the same tool would still require special handling.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing merge-tool implementations in ApprovalTests.cpp and how they locate tools across Linux, Mac, and Windows. Compare the repeated data and special handling for multiple versions, then determine whether a shared data-driven design can cover the documented cases without losing platform-specific behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.