Skip to content

Commit fe1fd3d

Browse files
committed
ci: RED tests for edits in branches that exclude Linux (Refs #896, #897)
1 parent 6a4235a commit fe1fd3d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎ci/test_ci_scope.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,29 @@ def test_platform_hunk_in_shared_c_file(self):
132132
other = diff_for(path, "@@ -15,0 +16 @@", "+\tint 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__\nint l;\n#else\nint o;\n#endif\n#ifndef __linux__\nint 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\nint w;\n#elif defined(__APPLE__)\nint m;\n#else\nint 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()\nelse()\n b()\nendif()\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", "+\tx();", "+#endif")

0 commit comments

Comments
 (0)