|
6 | 6 | # test_config_paths_defaults_match_current_values |
7 | 7 | # test_config_paths_reads_custom_config |
8 | 8 | # test_config_paths_idempotent_sourcing |
| 9 | +# test_config_paths_visual_baseline_path |
| 10 | +# test_config_paths_reads_from_dot_claude_dso_config |
| 11 | +# test_config_paths_no_claude_plugin_root_fallback |
9 | 12 | # |
10 | 13 | # Usage: bash tests/hooks/test-config-paths.sh |
11 | 14 | # Exit code: 0 if all pass, 1 if any fail |
@@ -164,6 +167,92 @@ result=$( |
164 | 167 |
|
165 | 168 | assert_eq "visual baseline from config" "app/tests/e2e/snapshots/" "$(echo "$result" | grep '^CFG_VISUAL_BASELINE_PATH=' | cut -d= -f2-)" |
166 | 169 |
|
| 170 | +# ============================================================================ |
| 171 | +# test_config_paths_reads_from_dot_claude_dso_config |
| 172 | +# ============================================================================ |
| 173 | +echo "=== test_config_paths_reads_from_dot_claude_dso_config ===" |
| 174 | + |
| 175 | +# REVIEW-DEFENSE: These two new tests (test_config_paths_reads_from_dot_claude_dso_config and |
| 176 | +# test_config_paths_no_claude_plugin_root_fallback) are intentionally FAILING. This file is the |
| 177 | +# RED phase of a TDD cycle (story dso-c2tl). The tests define the expected behavior of a |
| 178 | +# config-paths.sh change that will be implemented in the GREEN phase (story dso-6trc). Failing |
| 179 | +# tests at this stage are correct and expected — they confirm the behavior does not yet exist. |
| 180 | + |
| 181 | +# When CLAUDE_PLUGIN_ROOT is NOT set but .claude/dso-config.conf exists at git root, |
| 182 | +# config-paths.sh should read config values from .claude/dso-config.conf (new behavior). |
| 183 | +tmpdir_dso=$(mktemp -d) |
| 184 | +_CLEANUP_DIRS+=("$tmpdir_dso") |
| 185 | + |
| 186 | +# Set up a minimal git repo with .claude/dso-config.conf |
| 187 | +( |
| 188 | + cd "$tmpdir_dso" |
| 189 | + git init -q |
| 190 | + mkdir -p .claude |
| 191 | + cat > .claude/dso-config.conf <<'CONF' |
| 192 | +paths.app_dir=dotclaudeapp |
| 193 | +paths.src_dir=dotclaudesrc |
| 194 | +paths.test_dir=dotclaudetest |
| 195 | +interpreter.python_venv=dotclaudeapp/.venv/bin/python3 |
| 196 | +CONF |
| 197 | + git add .claude/dso-config.conf |
| 198 | + git commit -q -m "init" |
| 199 | +) |
| 200 | + |
| 201 | +result_dso=$( |
| 202 | + unset CLAUDE_PLUGIN_ROOT |
| 203 | + unset _CONFIG_PATHS_LOADED |
| 204 | + cd "$tmpdir_dso" |
| 205 | + source "$DSO_PLUGIN_DIR/hooks/lib/config-paths.sh" |
| 206 | + echo "CFG_APP_DIR=$CFG_APP_DIR" |
| 207 | + echo "CFG_SRC_DIR=$CFG_SRC_DIR" |
| 208 | + echo "CFG_TEST_DIR=$CFG_TEST_DIR" |
| 209 | +) |
| 210 | + |
| 211 | +assert_eq "dot-claude dso-config CFG_APP_DIR" "dotclaudeapp" "$(echo "$result_dso" | grep '^CFG_APP_DIR=' | cut -d= -f2-)" |
| 212 | +assert_eq "dot-claude dso-config CFG_SRC_DIR" "dotclaudesrc" "$(echo "$result_dso" | grep '^CFG_SRC_DIR=' | cut -d= -f2-)" |
| 213 | +assert_eq "dot-claude dso-config CFG_TEST_DIR" "dotclaudetest" "$(echo "$result_dso" | grep '^CFG_TEST_DIR=' | cut -d= -f2-)" |
| 214 | + |
| 215 | +# ============================================================================ |
| 216 | +# test_config_paths_no_claude_plugin_root_fallback |
| 217 | +# ============================================================================ |
| 218 | +echo "=== test_config_paths_no_claude_plugin_root_fallback ===" |
| 219 | + |
| 220 | +# REVIEW-DEFENSE: This test intentionally contradicts test_config_paths_reads_custom_config. |
| 221 | +# Once dso-6trc implements the new config-paths.sh behavior, the existing |
| 222 | +# test_config_paths_reads_custom_config test will need to be updated or removed — that update |
| 223 | +# is explicitly in scope for story dso-6trc (GREEN phase). Having two temporarily contradictory |
| 224 | +# tests is the correct state during a RED phase that changes config lookup semantics. |
| 225 | + |
| 226 | +# When CLAUDE_PLUGIN_ROOT is set to a dir containing workflow-config.conf, |
| 227 | +# config-paths.sh must NOT read from that file (new behavior: CLAUDE_PLUGIN_ROOT no |
| 228 | +# longer used for config file lookup). Values should fall back to defaults. |
| 229 | +tmpdir_cproot=$(mktemp -d) |
| 230 | +_CLEANUP_DIRS+=("$tmpdir_cproot") |
| 231 | + |
| 232 | +cat > "$tmpdir_cproot/workflow-config.conf" <<'CONF' |
| 233 | +paths.app_dir=cproot_app |
| 234 | +paths.src_dir=cproot_src |
| 235 | +CONF |
| 236 | + |
| 237 | +result_cproot=$( |
| 238 | + export CLAUDE_PLUGIN_ROOT="$tmpdir_cproot" |
| 239 | + unset _CONFIG_PATHS_LOADED |
| 240 | + # No .claude/dso-config.conf at git root → should fall back to defaults, NOT read CLAUDE_PLUGIN_ROOT |
| 241 | + tmpdir_gitroot=$(mktemp -d) |
| 242 | + cd "$tmpdir_gitroot" |
| 243 | + git init -q |
| 244 | + # no .claude/dso-config.conf here |
| 245 | + source "$DSO_PLUGIN_DIR/hooks/lib/config-paths.sh" |
| 246 | + echo "CFG_APP_DIR=$CFG_APP_DIR" |
| 247 | + echo "CFG_SRC_DIR=$CFG_SRC_DIR" |
| 248 | + rm -rf "$tmpdir_gitroot" |
| 249 | +) |
| 250 | + |
| 251 | +# After the new behavior, CLAUDE_PLUGIN_ROOT/workflow-config.conf must be ignored. |
| 252 | +# CFG_APP_DIR must be the default "app", NOT "cproot_app". |
| 253 | +assert_eq "CLAUDE_PLUGIN_ROOT not used: CFG_APP_DIR should be default" "app" "$(echo "$result_cproot" | grep '^CFG_APP_DIR=' | cut -d= -f2-)" |
| 254 | +assert_eq "CLAUDE_PLUGIN_ROOT not used: CFG_SRC_DIR should be default" "src" "$(echo "$result_cproot" | grep '^CFG_SRC_DIR=' | cut -d= -f2-)" |
| 255 | + |
167 | 256 | # ============================================================================ |
168 | 257 | # Summary |
169 | 258 | # ============================================================================ |
|
0 commit comments