@@ -132,6 +132,29 @@ def test_platform_hunk_in_shared_c_file(self):
132132 other = diff_for (path , "@@ -15,0 +16 @@" , "+\t int added = 0;" )
133133 self .check ([path ], core = True , windows = True , diff = other , text = SHARED_C )
134134
135+ def test_branches_excluding_linux_reach_macos_and_windows (self ):
136+ # `#else` of `#ifdef __linux__` and `#ifndef __linux__` are the code
137+ # macOS and Windows compile (#897).
138+ path = "frontend/components/ColorSourceToolbar.cpp"
139+ text = "int a;\n #ifdef __linux__\n int l;\n #else\n int o;\n #endif\n #ifndef __linux__\n int n;\n #endif\n "
140+ diff = diff_for (path , "@@ -4,0 +5 @@" , "+int added;" )
141+ self .check ([path ], macos = True , windows = True , diff = diff , text = text )
142+ diff = diff_for (path , "@@ -7,0 +8 @@" , "+int added;" )
143+ self .check ([path ], macos = True , windows = True , diff = diff , text = text )
144+ # Inside the Linux branch itself: Linux only.
145+ diff = diff_for (path , "@@ -2,0 +3 @@" , "+int added;" )
146+ self .check ([path ], diff = diff , text = text )
147+ # `#else` after both macOS and Windows branches: Linux only.
148+ text = "#ifdef _WIN32\n int w;\n #elif defined(__APPLE__)\n int m;\n #else\n int o;\n #endif\n "
149+ diff = diff_for (path , "@@ -5,0 +6 @@" , "+int added;" )
150+ self .check ([path ], diff = diff , text = text )
151+
152+ def test_cmake_else_of_linux_reaches_macos_and_windows (self ):
153+ path = "plugins/obs-ffmpeg/CMakeLists.txt"
154+ text = "if(OS_LINUX)\n a()\n else()\n b()\n endif()\n "
155+ diff = diff_for (path , "@@ -3,0 +4 @@" , "+ c()" )
156+ self .check ([path ], macos = True , windows = True , diff = diff , text = text )
157+
135158 def test_hunk_naming_a_platform_macro (self ):
136159 path = "libobs/obs.c"
137160 diff = diff_for (path , "@@ -3,0 +4,3 @@ static int plain(void)" , "+#ifdef _WIN32" , "+\t x();" , "+#endif" )
0 commit comments