Skip to content

Commit

Permalink
tests: test proper merge-base handling
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Nov 20, 2024
1 parent 9f57049 commit 140b4de
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/differential.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,19 @@ test_differential_checkton() {
test_differential_checkton no-new-issues \
"$R/patches/0001-Rename-tektontask-to-cooltask.patch"
}

@test "don't report issues already fixed in target branch but still present in source branch" {
git am "$R/patches/0001-Add-another-unquoted-variable.patch"

# the issue got fixed in the target branch
git revert HEAD --no-edit
local diff_base
diff_base=$(git rev-parse HEAD)

# but our source branch forked from a point before the issue was fixed
git checkout HEAD^ -b source-branch
git am "$R/patches/0001-Modify-without-introducing-issues.patch"

CHECKTON_DIFF_BASE=$diff_base \
test_differential_checkton dont-report-stale-issues
}
25 changes: 25 additions & 0 deletions test/resources/differential/dont-report-stale-issues/csdiff.sarif
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
"version": "2.1.0",
"inlineExternalProperties": [
{
"externalizedProperties": {
"tool": "ShellCheck",
"tool-url": "https://www.shellcheck.net/wiki/",
"tool-version": "0.10.0"
}
}
],
"runs": [
{
"tool": {
"driver": {
"name": "ShellCheck",
"version": "0.10.0",
"informationUri": "https://www.shellcheck.net/wiki/"
}
},
"results": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From deadbeef01deadbeef02deadbeef03deadbeef04 Mon Sep 17 00:00:00 2001
From: Checkton Patcher <[email protected]>
Date: Thu, 20 Jun 2024 16:00:00 +0000
Subject: [PATCH] Modify without introducing issues

---
test/resources/files-to-check/tektontask.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/test/resources/files-to-check/tektontask.yaml b/test/resources/files-to-check/tektontask.yaml
index 150a030..7b1c648 100644
--- a/test/resources/files-to-check/tektontask.yaml
+++ b/test/resources/files-to-check/tektontask.yaml
@@ -34,3 +34,4 @@ spec:
#!/bin/bash -e -u -o pipefail
echo "I mean, if I went around saying I was an emperor just because some moistened bint had lobbed a scimitar at me, they'd put me away!"
echo $HI
+status: {}
--
2.45.1

4 changes: 4 additions & 0 deletions test/resources/patches/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ EOF
git add "$tektontask"
_commit_and_save_patch "Add another unquoted variable"

echo "status: {}" >> "$tektontask"
git add "$tektontask"
_commit_and_save_patch "Modify without introducing issues"

sed -i 's/^From [0-9a-f]*/From deadbeef01deadbeef02deadbeef03deadbeef04/' \
test/resources/patches/*.patch

Expand Down

0 comments on commit 140b4de

Please sign in to comment.