|
KiCad PCB EDA Suite
|
Regression tests for LIBGIT_BACKEND, KIGIT_COMMON, GIT_INIT_HANDLER, GIT_PULL_HANDLER, GIT_PUSH_HANDLER, GIT_COMMIT_HANDLER focused on the recent Git integration bug fixes and the Amend Last Commit feature. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <git/git_backend.h>#include <git/libgit_backend.h>#include <git/kicad_git_common.h>#include <git/git_status_handler.h>#include <git/project_git_utils.h>#include <git/git_init_handler.h>#include <git/git_pull_handler.h>#include <git/git_push_handler.h>#include <git/git_commit_handler.h>#include <git2.h>#include <fstream>#include <wx/ffile.h>#include <wx/filename.h>#include <wx/textfile.h>#include <wx/utils.h>Go to the source code of this file.
Classes | |
| struct | GIT_BACKEND_FIXTURE |
| Build a temp directory tree containing a local working repo with one commit and a bare "remote" repo cloned from it. More... | |
Functions | |
| BOOST_AUTO_TEST_CASE (IsWithinProjectPath_ScopesToProjectDirectory) | |
| The commit/amend checklists scope files to the project directory so that unrelated files elsewhere in the repository do not leak into the commit (issue #15910). | |
| BOOST_AUTO_TEST_CASE (AmendFileList_ExcludesFilesOutsideProject) | |
| Regression for issue #15910: the Amend Last Commit checklist is seeded from a tree diff of the previous commit. | |
| BOOST_AUTO_TEST_CASE (GetUpstreamShorthand_NoUpstreamFallsBackToRemoteSlashBranch) | |
| When the local branch has no upstream configured, GetUpstreamShorthand must synthesise <remote>/<branch> so the pull fallback and first-push paths have a meaningful target to display and act on. | |
| BOOST_AUTO_TEST_CASE (GetDifferentFiles_SameTreeAmendHidesAheadFiles) | |
| Regression for the spurious clock icon after a message-only amend: when HEAD and the upstream tracking ref point at different commit OIDs but the commits share an identical tree, no file should be reported as AHEAD or BEHIND. | |
| BOOST_AUTO_TEST_CASE (GetDifferentFiles_DifferentTreeAmendKeepsAheadFile) | |
| Positive control: if the amend genuinely changes the file content, the file should still appear in the AHEAD set. | |
| BOOST_AUTO_TEST_CASE (PerformPull_NoUpstreamConfig_FallbackSucceedsAndWritesUpstream) | |
Regression for the original issue #24332 surface: pull on a fresh repo where Add Version Control wired up origin but never set per-branch upstream tracking used to fail with "Could not lookup commit" because FETCH_HEAD has no merge-marked entry. | |
| BOOST_AUTO_TEST_CASE (Push_FirstPushSetsUpstreamTracking) | |
| Push -u behavior: after the first successful push from a branch with no upstream configured, branch. | |
| BOOST_AUTO_TEST_CASE (Amend_MessageOnlyRewritesHeadKeepsTree) | |
| Amend rewrites HEAD with a new commit OID. | |
| BOOST_AUTO_TEST_CASE (Amend_StagedFileChangesTreeAndKeepsParent) | |
| Amend with new files: the tree changes and includes the newly staged content. | |
| BOOST_AUTO_TEST_CASE (Amend_UnbornBranchReturnsError) | |
| Amending an unborn branch (a fresh repo with no commits yet) must fail cleanly rather than crash or produce a bogus commit. | |
| BOOST_AUTO_TEST_CASE (InitializeRepository_SeedsGitignoreWithKicadEntries) | |
| InitializeRepository seeds a project-level .gitignore with KiCad-specific transient paths (.history/, -backups/, _autosave-, fp-info-cache, ~*.lck). | |
| BOOST_AUTO_TEST_CASE (InitializeRepository_GitignoreDoesNotDuplicateEntries) | |
| InitializeRepository must not duplicate entries that the user (or a template) has already written. | |
Variables | |
| static const char * | TEST_AUTHOR_NAME = "Test Author" |
| static const char * | TEST_AUTHOR_EMAIL = "[email protected]" |
Regression tests for LIBGIT_BACKEND, KIGIT_COMMON, GIT_INIT_HANDLER, GIT_PULL_HANDLER, GIT_PUSH_HANDLER, GIT_COMMIT_HANDLER focused on the recent Git integration bug fixes and the Amend Last Commit feature.
Definition in file test_libgit_backend.cpp.
| BOOST_AUTO_TEST_CASE | ( | Amend_MessageOnlyRewritesHeadKeepsTree | ) |
Amend rewrites HEAD with a new commit OID.
For a message-only amend, the tree (and therefore the working tree) is unchanged.
Definition at line 649 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), GIT_COMMIT_HANDLER::PerformAmend(), result, Success, TEST_AUTHOR_EMAIL, and TEST_AUTHOR_NAME.
| BOOST_AUTO_TEST_CASE | ( | Amend_StagedFileChangesTreeAndKeepsParent | ) |
Amend with new files: the tree changes and includes the newly staged content.
Definition at line 694 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), GIT_COMMIT_HANDLER::PerformAmend(), result, Success, TEST_AUTHOR_EMAIL, and TEST_AUTHOR_NAME.
| BOOST_AUTO_TEST_CASE | ( | Amend_UnbornBranchReturnsError | ) |
Amending an unborn branch (a fresh repo with no commits yet) must fail cleanly rather than crash or produce a bogus commit.
Definition at line 753 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), Error, GIT_COMMIT_HANDLER::GetErrorString(), GIT_COMMIT_HANDLER::PerformAmend(), result, TEST_AUTHOR_EMAIL, and TEST_AUTHOR_NAME.
| BOOST_AUTO_TEST_CASE | ( | AmendFileList_ExcludesFilesOutsideProject | ) |
Regression for issue #15910: the Amend Last Commit checklist is seeded from a tree diff of the previous commit.
Files that commit touched outside the current project directory must be filtered out with IsWithinProjectPath, exactly as the amend handler does, instead of leaking into the dialog.
Definition at line 336 of file test_libgit_backend.cpp.
References BOOST_CHECK_MESSAGE(), delta, GIT_STATUS_HANDLER::GetWorkingDirectory(), index, KIGIT::PROJECT_GIT_UTILS::IsWithinProjectPath(), path, KIGIT_COMMON::SetProjectDir(), TEST_AUTHOR_EMAIL, TEST_AUTHOR_NAME, and ToStdString().
| BOOST_AUTO_TEST_CASE | ( | GetDifferentFiles_DifferentTreeAmendKeepsAheadFile | ) |
Positive control: if the amend genuinely changes the file content, the file should still appear in the AHEAD set.
Verifies the content-aware filter doesn't over-filter.
Definition at line 544 of file test_libgit_backend.cpp.
References BOOST_CHECK_MESSAGE(), and KIGIT_COMMON::GetDifferentFiles().
| BOOST_AUTO_TEST_CASE | ( | GetDifferentFiles_SameTreeAmendHidesAheadFiles | ) |
Regression for the spurious clock icon after a message-only amend: when HEAD and the upstream tracking ref point at different commit OIDs but the commits share an identical tree, no file should be reported as AHEAD or BEHIND.
Without the content-aware filter in GetDifferentFiles, the AHEAD set would contain every file touched by the local commit relative to the merge-base.
Definition at line 481 of file test_libgit_backend.cpp.
References BOOST_CHECK_MESSAGE(), KIGIT_COMMON::GetDifferentFiles(), TEST_AUTHOR_EMAIL, and TEST_AUTHOR_NAME.
| BOOST_AUTO_TEST_CASE | ( | GetUpstreamShorthand_NoUpstreamFallsBackToRemoteSlashBranch | ) |
When the local branch has no upstream configured, GetUpstreamShorthand must synthesise <remote>/<branch> so the pull fallback and first-push paths have a meaningful target to display and act on.
Definition at line 455 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), and KIGIT_COMMON::GetUpstreamShorthand().
| BOOST_AUTO_TEST_CASE | ( | InitializeRepository_GitignoreDoesNotDuplicateEntries | ) |
InitializeRepository must not duplicate entries that the user (or a template) has already written.
An existing .history/ line should be left alone while the other four KiCad defaults are appended.
Definition at line 818 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), GIT_INIT_HANDLER::InitializeRepository(), result, and Success.
| BOOST_AUTO_TEST_CASE | ( | InitializeRepository_SeedsGitignoreWithKicadEntries | ) |
InitializeRepository seeds a project-level .gitignore with KiCad-specific transient paths (.history/, -backups/, _autosave-, fp-info-cache, ~*.lck).
Definition at line 780 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), GIT_INIT_HANDLER::InitializeRepository(), result, and Success.
| BOOST_AUTO_TEST_CASE | ( | IsWithinProjectPath_ScopesToProjectDirectory | ) |
The commit/amend checklists scope files to the project directory so that unrelated files elsewhere in the repository do not leak into the commit (issue #15910).
IsWithinProjectPath is the single scope predicate shared by every checklist path in the project manager.
Definition at line 304 of file test_libgit_backend.cpp.
References BOOST_AUTO_TEST_CASE(), KIGIT::PROJECT_GIT_UTILS::IsWithinProjectPath(), and project.
| BOOST_AUTO_TEST_CASE | ( | PerformPull_NoUpstreamConfig_FallbackSucceedsAndWritesUpstream | ) |
Regression for the original issue #24332 surface: pull on a fresh repo where Add Version Control wired up origin but never set per-branch upstream tracking used to fail with "Could not lookup commit" because FETCH_HEAD has no merge-marked entry.
The fallback in PerformPull resolves the implicit target via refs/remotes/origin/<branch> and persists the upstream config.
Definition at line 583 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), FastForward, KIGIT_ERRORS::GetErrorString(), GIT_PULL_HANDLER::PerformPull(), result, Success, and UpToDate.
| BOOST_AUTO_TEST_CASE | ( | Push_FirstPushSetsUpstreamTracking | ) |
Push -u behavior: after the first successful push from a branch with no upstream configured, branch.
<name>.merge and .remote should be populated so subsequent pull/push hit the FETCH_HEAD path instead of the fallback.
Definition at line 618 of file test_libgit_backend.cpp.
References BOOST_CHECK_EQUAL(), GIT_PUSH_HANDLER::PerformPush(), result, and Success.
|
static |
Definition at line 50 of file test_libgit_backend.cpp.
Referenced by GIT_BACKEND_FIXTURE::createCommit(), and GIT_BACKEND_FIXTURE::initRepoWithCommit().
|
static |
Definition at line 49 of file test_libgit_backend.cpp.
Referenced by GIT_BACKEND_FIXTURE::createCommit(), and GIT_BACKEND_FIXTURE::initRepoWithCommit().