aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-07-19 14:29:13 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-07-20 06:14:22 +0000
commit81b6c9ef8c27404778abe749b87bf5d0a5707c82 (patch)
tree336aa10447fd4c8da904cdb0dd4b39e12e8fd43a
parentc206f3cb1d3601e1843e3bfd6f194dd585bbc13f (diff)
downloadmeson-81b6c9ef8c27404778abe749b87bf5d0a5707c82.zip
meson-81b6c9ef8c27404778abe749b87bf5d0a5707c82.tar.gz
meson-81b6c9ef8c27404778abe749b87bf5d0a5707c82.tar.bz2
unit tests: Use a timeout for tests that use the network
It's better to quickly skip when the network is unavailable or slow.
-rwxr-xr-xrun_unittests.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 7bd459d..0bb532a 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -68,6 +68,10 @@ from run_tests import (
run_configure_inprocess, run_mtest_inprocess
)
+
+URLOPEN_TIMEOUT = 5
+
+
def get_dynamic_section_entry(fname, entry):
if is_cygwin() or is_osx():
raise unittest.SkipTest('Test only applicable to ELF platforms')
@@ -1150,7 +1154,9 @@ class DataTests(unittest.TestCase):
interp = Interpreter(FakeBuild(env), mock=True)
url = 'https://raw.githubusercontent.com/TingPing/language-meson/master/grammars/meson.json'
try:
- r = urllib.request.urlopen(url)
+ # Use a timeout to avoid blocking forever in case the network is
+ # slow or unavailable in a weird way
+ r = urllib.request.urlopen(url, timeout=URLOPEN_TIMEOUT)
except urllib.error.URLError as e:
# Skip test when network is not available, such as during packaging
# by a distro or Flatpak