Skip to content

Commit a192c14

Browse files
author
Test User
committed
Fix change impact relation ordering to prioritize verifiedBy
When building change impact trees, relations are now processed in priority order: verifiedBy first, then satisfiedBy, then derive. This prevents verifications from being marked as 'already visited' when sibling requirements traverse them through derive relations. Without this fix, when a parent requirement had both derive and verifiedBy relations, the derive relation would be processed first, causing sibling requirements to visit shared verifications before the parent could add them to its own change impact tree. - Add relation sorting in build_change_impact_tree - Update test expectations to match new correct ordering - Add test-change-impact-edgecase for multi-file verification references
1 parent e7fc3b4 commit a192c14

File tree

8 files changed

+107
-73
lines changed

8 files changed

+107
-73
lines changed

tests/test-change-impact-detection/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ EXPECTED_CONTENT='## Change Impact Report
6767
### Changed Elements
6868
6969
* [Power Saving Mode](Requirements.md#power-saving-mode)
70+
* verifiedBy -> [Power Saving](Requirements.md#power-saving) ⚠️
71+
* satisfiedBy -> [software/power_control.txt](software/power_control.txt)
7072
* derive -> [CPU Power Reduction](Requirements.md#cpu-power-reduction)
7173
* verifiedBy -> [CPU Throttling](Requirements.md#cpu-throttling)
7274
* satisfiedBy -> [software/cpu_manager.txt](software/cpu_manager.txt)
73-
* verifiedBy -> [Power Saving](Requirements.md#power-saving) ⚠️
7475
* derive -> [Screen Brightness Adjustment](Requirements.md#screen-brightness-adjustment)
7576
* verifiedBy -> [Screen Brightness](Requirements.md#screen-brightness)
76-
* satisfiedBy -> [software/power_control.txt](software/power_control.txt)
7777
7878
7979
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore patterns for test
2+
.git/
3+
*.log
4+
expected_impact.md
File renamed without changes.
File renamed without changes.

tests/test-change-impact-head2/expected_impact.md renamed to tests/test-change-impact-edgecase/expected_impact.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* verifiedBy -> [Validate Plugin Removal](Verifications.md#validate-plugin-removal)
1111

1212

13+
1314
---
1415

1516
## Invalidated Verifications
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Create log file immediately to ensure it exists for runner
5+
echo "Starting test..." > "${TEST_DIR}/test_results.log"
6+
7+
# Test: Change Impact Detection for Details Changes
8+
# --------------------------------------
9+
# Acceptance Criteria:
10+
# - When a requirement's Details section is modified, the change should be detected
11+
# - The change impact tree should show verifiedBy relations
12+
# - Invalidated Verifications section should list affected verifications
13+
#
14+
# Test Criteria:
15+
# - Command exits with success (0) return code
16+
# - Change impact report shows the changed requirement
17+
# - The verifiedBy relation appears in the change impact tree
18+
# - The verification appears in "Invalidated Verifications" section
19+
20+
21+
# Dummy Commit
22+
cd "${TEST_DIR}"
23+
echo "test" > test.txt
24+
git add -A :/
25+
git commit -m "dummy commit" > /dev/null 2>&1
26+
27+
28+
# Now modify the Details section of Add Plugin requirement
29+
sed -i 's/The plugin should be added to all nodes part of the deployment./The plugin should be added to all nodes part of the deployment including replicas./' "${TEST_DIR}/Requirements.md"
30+
31+
# Also modify the main content of Remove Plugin requirement
32+
sed -i 's/The plugin should be removied from all nodes part of the deployment./The plugin should be removied from all nodes part of the deployment including replica./' "${TEST_DIR}/Requirements.md"
33+
34+
# Dummy Commit
35+
cd "${TEST_DIR}"
36+
git add -A :/
37+
git commit -m "dummy commit" > /dev/null 2>&1
38+
39+
# Dummy Commit
40+
cd "${TEST_DIR}"
41+
echo "test2" > test.txt
42+
git add -A :/
43+
git commit -m "dummy commit" > /dev/null 2>&1
44+
45+
46+
# Test 1: Run change impact detection comparing HEAD to HEAD~1
47+
echo "Running: reqvire change-impact --git-commit=HEAD~1" >> "${TEST_DIR}/test_results.log"
48+
set +e
49+
OUTPUT=$(cd "${TEST_DIR}" && "${REQVIRE_BIN}" change-impact --git-commit=HEAD~2 2>&1)
50+
EXIT_CODE=$?
51+
set -e
52+
53+
echo "Exit code: $EXIT_CODE" >> "${TEST_DIR}/test_results.log"
54+
printf "%s\n" "$OUTPUT" >> "${TEST_DIR}/test_results.log"
55+
56+
# Write output to log file for debugging
57+
printf "%s\n" "$OUTPUT" > "${TEST_DIR}/test_results_default.log"
58+
59+
# Extract important parts (excluding log messages)
60+
GOTTEN_CONTENT=$(echo "$OUTPUT" | grep -v "INFO reqvire::config" | grep -v "Warning: Element" | grep -v "DEBUG:")
61+
SANITIZED_OUTPUT=$(echo "$GOTTEN_CONTENT" | sed -E 's#https://[^ )]+/blob/[a-f0-9]{7,40}/##g')
62+
63+
# Load expected content from file
64+
EXPECTED_CONTENT=$(cat "${TEST_DIR}/expected_impact.md")
65+
66+
# Check exit code AFTER extracting output for better error messages
67+
if [ $EXIT_CODE -ne 0 ]; then
68+
echo "❌ FAILED: Change impact detection failed with exit code $EXIT_CODE"
69+
echo ""
70+
echo "Expected:"
71+
echo "$EXPECTED_CONTENT"
72+
echo ""
73+
echo "Got:"
74+
echo "$SANITIZED_OUTPUT"
75+
echo ""
76+
diff -u <(echo "$EXPECTED_CONTENT") <(echo "$SANITIZED_OUTPUT") || true
77+
rm -rf "${TEST_DIR}"
78+
exit 1
79+
fi
80+
81+
# Test 1: Verify that change impact report shows verifiedBy relation
82+
if ! diff <(echo "$EXPECTED_CONTENT") <(echo "$SANITIZED_OUTPUT") > /dev/null; then
83+
echo "❌ FAILED: Change impact report missing verifiedBy relation or invalidated verifications."
84+
echo ""
85+
echo "Expected:"
86+
echo "$EXPECTED_CONTENT"
87+
echo ""
88+
echo "Got:"
89+
echo "$SANITIZED_OUTPUT"
90+
echo ""
91+
diff -u <(echo "$EXPECTED_CONTENT") <(echo "$SANITIZED_OUTPUT") || true
92+
rm -rf "${TEST_DIR}"
93+
exit 1
94+
fi
95+
96+
97+
# Clean up
98+
rm -rf "${TEST_DIR}"
99+
exit 0

tests/test-change-impact-head2/test.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/test-change-impact-smart-filtering/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ EXPECTED_CONTENT='## Change Impact Report
8888
### New Elements
8989
9090
* [New Parent Requirement](Requirements.md#new-parent-requirement)
91-
* derive -> [New Child Requirement](Requirements.md#new-child-requirement) (new)
9291
* verifiedBy -> [New Verification](Requirements.md#new-verification) (new)
92+
* derive -> [New Child Requirement](Requirements.md#new-child-requirement) (new)
9393
9494
9595

0 commit comments

Comments
 (0)