test(joinir): fix Phase 33-3.2 test flakiness by unifying env-dependent tests

Phase 33-3.2 test stabilization:
- Unified 4 env-dependent tests into 1 (test_if_select_pattern_matching)
- Eliminated race condition from parallel test execution
- All 5 tests now pass consistently (5/5 stable PASS)

Before: 8 tests (flaky 7-8/8 due to env var race)
After: 5 tests (stable 5/5, no flakiness)

Test coverage maintained:
- Simple pattern lowering (env ON)
- Local pattern lowering (env ON)
- Disabled by default (env OFF)
- Wrong function name filter (env ON)
- 4 verify tests (env-independent, kept separate)

Documentation:
- Updated TASKS.md with test flake resolution notes
- Updated docs/private submodule to 81ec67f

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-27 04:27:57 +09:00
parent 4ba3fcd615
commit bb4e3044a8
2 changed files with 11 additions and 30 deletions

View File

@ -124,15 +124,17 @@ mod tests {
}
}
/// Phase 33-3: 統合パターンマッチングテストenv 競合回避)
///
/// env 変数を触る4つのテストを1つにまとめて、並列実行でのレースを防ぐ。
/// 順番に: simple/local/disabled/wrong_name を確認する。
#[test]
fn test_if_select_simple_pattern() {
// Set environment variable for this test
fn test_if_select_pattern_matching() {
// ==== 1. Simple pattern (env ON) ====
std::env::set_var("NYASH_JOINIR_IF_SELECT", "1");
let func = create_simple_pattern_mir();
let entry_block = func.entry_block;
// Try to lower to JoinIR
let result = try_lower_if_to_joinir(&func, entry_block, true);
assert!(
@ -153,18 +155,9 @@ mod tests {
panic!("Expected JoinInst::Select, got {:?}", result);
}
// Clean up
std::env::remove_var("NYASH_JOINIR_IF_SELECT");
}
#[test]
fn test_if_select_local_pattern() {
std::env::set_var("NYASH_JOINIR_IF_SELECT", "1");
// ==== 2. Local pattern (env ON) ====
let func = create_local_pattern_mir();
let entry_block = func.entry_block;
// Try to lower to JoinIR
let result = try_lower_if_to_joinir(&func, entry_block, true);
assert!(
@ -185,18 +178,11 @@ mod tests {
panic!("Expected JoinInst::Select, got {:?}", result);
}
std::env::remove_var("NYASH_JOINIR_IF_SELECT");
}
#[test]
fn test_if_select_disabled_by_default() {
// Ensure environment variable is NOT set
// ==== 3. Disabled by default (env OFF) ====
std::env::remove_var("NYASH_JOINIR_IF_SELECT");
let func = create_simple_pattern_mir();
let entry_block = func.entry_block;
// Should return None when disabled
let result = try_lower_if_to_joinir(&func, entry_block, false);
assert!(
@ -205,19 +191,13 @@ mod tests {
);
eprintln!("✅ If/Select lowering correctly disabled by default");
}
#[test]
fn test_if_select_wrong_function_name() {
// ==== 4. Wrong function name (env ON) ====
std::env::set_var("NYASH_JOINIR_IF_SELECT", "1");
// Create function with wrong name (not IfSelectTest.*)
let mut func = create_simple_pattern_mir();
func.signature.name = "WrongName.test/1".to_string();
let entry_block = func.entry_block;
// Should return None for non-IfSelectTest functions
let result = try_lower_if_to_joinir(&func, entry_block, true);
assert!(
@ -227,6 +207,7 @@ mod tests {
eprintln!("✅ Function name filter working correctly");
// Clean up
std::env::remove_var("NYASH_JOINIR_IF_SELECT");
}