Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.2KB

  1. #!/usr/bin/env python3
  2. # Copyright 2017 Christoph Reiter
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining
  5. # a copy of this software and associated documentation files (the
  6. # "Software"), to deal in the Software without restriction, including
  7. # without limitation the rights to use, copy, modify, merge, publish,
  8. # distribute, sublicense, and/or sell copies of the Software, and to
  9. # permit persons to whom the Software is furnished to do so, subject to
  10. # the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included
  13. # in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. """The goal of this test suite is collect tests for update regressions
  23. and to test msys2 related modifications like for path handling.
  24. Feel free to extend.
  25. """
  26. import os
  27. import unittest
  28. if "MSYSTEM" in os.environ:
  29. SEP = "/"
  30. else:
  31. SEP = "\\"
  32. class Tests(unittest.TestCase):
  33. def test_sep(self):
  34. self.assertEqual(os.sep, SEP)
  35. def test_module_file_path(self):
  36. import asyncio
  37. import zlib
  38. self.assertEqual(zlib.__file__, os.path.normpath(zlib.__file__))
  39. self.assertEqual(asyncio.__file__, os.path.normpath(asyncio.__file__))
  40. def test_importlib_frozen_path_sep(self):
  41. import importlib._bootstrap_external
  42. self.assertEqual(importlib._bootstrap_external.path_sep, SEP)
  43. def test_os_commonpath(self):
  44. self.assertEqual(
  45. os.path.commonpath(
  46. [os.path.join("C:", os.sep, "foo", "bar"),
  47. os.path.join("C:", os.sep, "foo")]),
  48. os.path.join("C:", os.sep, "foo"))
  49. def test_pathlib(self):
  50. import pathlib
  51. p = pathlib.Path("foo") / pathlib.Path("foo")
  52. self.assertEqual(str(p), os.path.normpath(p))
  53. def test_modules_import(self):
  54. import sqlite3
  55. import ssl
  56. import ctypes
  57. def test_socket_inet_ntop(self):
  58. import socket
  59. self.assertTrue(hasattr(socket, "inet_ntop"))
  60. def test_socket_inet_pton(self):
  61. import socket
  62. self.assertTrue(hasattr(socket, "inet_pton"))
  63. def test_multiprocessing_queue(self):
  64. from multiprocessing import Queue
  65. Queue(0)
  66. def test_socket_timout_normal_error(self):
  67. import urllib.request
  68. from urllib.error import URLError
  69. try:
  70. urllib.request.urlopen(
  71. 'http://localhost', timeout=0.0001).close()
  72. except URLError:
  73. pass
  74. def test_threads(self):
  75. from concurrent.futures import ThreadPoolExecutor
  76. with ThreadPoolExecutor(1) as pool:
  77. for res in pool.map(lambda *x: None, range(10000)):
  78. pass
  79. def test_sysconfig(self):
  80. import sysconfig
  81. # This should be able to execute without exceptions
  82. sysconfig.get_config_vars()
  83. def test_sqlite_enable_load_extension(self):
  84. # Make sure --enable-loadable-sqlite-extensions is used
  85. import sqlite3
  86. self.assertTrue(sqlite3.Connection.enable_load_extension)
  87. def test_venv_creation(self):
  88. import tempfile
  89. import venv
  90. import subprocess
  91. import shutil
  92. with tempfile.TemporaryDirectory() as tmp:
  93. builder = venv.EnvBuilder()
  94. builder.create(tmp)
  95. assert os.path.exists(os.path.join(tmp, "bin", "activate"))
  96. assert os.path.exists(os.path.join(tmp, "bin", "python.exe"))
  97. assert os.path.exists(os.path.join(tmp, "bin", "python3.exe"))
  98. subprocess.check_call([shutil.which("bash.exe"), os.path.join(tmp, "bin", "activate")])
  99. def suite():
  100. return unittest.TestLoader().loadTestsFromName(__name__)
  101. if __name__ == '__main__':
  102. unittest.main(defaultTest='suite')