PageRenderTime 60ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/IronPython/Lib/iptest/test_env.py

#
Python | 105 lines | 54 code | 24 blank | 27 comment | 23 complexity | 9596b80b33d1046fa96f32dc1bcd73ee MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. #####################################################################################
  2. #
  3. # Copyright (c) Microsoft Corporation. All rights reserved.
  4. #
  5. # This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. # copy of the license can be found in the License.html file at the root of this distribution. If
  7. # you cannot locate the Apache License, Version 2.0, please send an email to
  8. # ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. # by the terms of the Apache License, Version 2.0.
  10. #
  11. # You must not remove this notice, or any other, from this software.
  12. #
  13. #
  14. #####################################################################################
  15. import sys
  16. from iptest.util import get_env_var, get_temp_dir
  17. #------------------------------------------------------------------------------
  18. #--IronPython or something else?
  19. is_silverlight = sys.platform == 'silverlight'
  20. is_cli = sys.platform == 'cli'
  21. is_ironpython = is_silverlight or is_cli
  22. is_cpython = sys.platform == 'win32'
  23. if is_ironpython:
  24. #We'll use System, if available, to figure out more info on the test
  25. #environment later
  26. import System
  27. import clr
  28. #--The bittedness of the Python implementation
  29. is_cli32, is_cli64 = False, False
  30. if is_ironpython:
  31. is_cli32, is_cli64 = (System.IntPtr.Size == 4), (System.IntPtr.Size == 8)
  32. is_32, is_64 = is_cli32, is_cli64
  33. if not is_ironpython:
  34. cpu = get_env_var("PROCESSOR_ARCHITECTURE")
  35. if cpu.lower()=="x86":
  36. is_32 = True
  37. elif cpu.lower()=="amd64":
  38. is_64 = True
  39. #--CLR version we're running on (if any)
  40. is_orcas = False
  41. if is_cli:
  42. is_orcas = len(clr.GetClrType(System.Reflection.Emit.DynamicMethod).GetConstructors()) == 8
  43. is_net40 = False
  44. if is_cli:
  45. is_net40 = System.Environment.Version.Major==4
  46. is_dlr_in_ndp = False
  47. if is_net40:
  48. try:
  49. clr.AddReference("Microsoft.Scripting.Core")
  50. except:
  51. is_dlr_in_ndp = True
  52. #--Newlines
  53. if is_ironpython:
  54. newline = System.Environment.NewLine
  55. else:
  56. import os
  57. newline = os.linesep
  58. #--Build flavor of Python being tested
  59. is_debug = False
  60. if is_cli:
  61. is_debug = sys.exec_prefix.lower().endswith("debug")
  62. #--Are we using peverify to check that all IL generated is valid?
  63. is_peverify_run = False
  64. if is_cli:
  65. is_peverify_run = is_debug and "-X:SaveAssemblies" in System.Environment.CommandLine
  66. #--Internal checkin system used for IronPython
  67. is_snap = False
  68. if not is_silverlight and get_env_var("THISISSNAP")!=None:
  69. is_snap = True
  70. #--We only run certain time consuming test cases in the stress lab
  71. is_stress = False
  72. if not is_silverlight and get_env_var("THISISSTRESS")!=None:
  73. is_stress = True
  74. #--Are we running tests under the Vista operating system?
  75. is_vista = False
  76. if not is_silverlight and get_env_var("IS_VISTA")=="1":
  77. is_vista = True
  78. is_win7 = False
  79. if is_ironpython: #TODO - what about CPython?
  80. is_win7 = System.Environment.OSVersion.Version.Major==6 and System.Environment.OSVersion.Version.Minor==1
  81. #------------------------------------------------------------------------------