]> granicus.if.org Git - graphviz/commitdiff
try to work around `lneato -?` flakiness on Windows
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 25 Apr 2021 21:48:03 +0000 (14:48 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 1 May 2021 22:45:10 +0000 (15:45 -0700)
Related to #1934.

rtest/test_tools.py

index 61fd0266488b2cf20ceb5cda0ce660df232294e2..1ef4fa0954e926c83a2a78070a2e890a32f11ea0 100644 (file)
@@ -72,13 +72,36 @@ def test_tools(tool):
   environ_copy.pop("DISPLAY", None)
 
   # Test usage
-  output = subprocess.check_output(
-      [tool, "-?"],
-      env=environ_copy,
-      stdin=subprocess.DEVNULL,
-      stderr=subprocess.STDOUT,
-      universal_newlines=True,
-  )
+  p = subprocess.Popen([tool, "-?"], env=environ_copy, stdin=subprocess.DEVNULL,
+                       stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+                       universal_newlines=True)
+  output, _ = p.communicate()
+  ret = p.returncode
+
+  # FIXME: https://gitlab.com/graphviz/graphviz/-/issues/1934
+  # cope with flaky failures, while also failing if this flakiness has been
+  # fixed
+  if tool == "lneato" and os.getenv("build_system") == "msbuild":
+    has_pass = ret == 0
+    has_fail = ret != 0
+    for _ in range(100):
+      if has_pass and has_fail:
+        break
+      p = subprocess.Popen([tool, "-?"], env=environ_copy,
+                           stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
+                           stderr=subprocess.STDOUT, universal_newlines=True)
+      out, _ = p.communicate()
+      if p.returncode == 0:
+        has_pass = True
+        ret = p.returncode
+        output = out
+      else:
+        has_fail = True
+    assert has_pass, "could not find passing execution"
+    assert has_fail, "could not find failing execution (#1934 fixed?)"
+
+  assert ret == 0, f"`{tool} -?` failed"
+
   assert re.match("usage", output, flags=re.IGNORECASE) is not None, \
     f"{tool} -? did not show usage"