PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 8ms 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 | 25 complexity | 9596b80b33d1046fa96f32dc1bcd73ee MD5 | raw file
  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
 16import sys
 17from iptest.util import get_env_var, get_temp_dir
 18
 19#------------------------------------------------------------------------------
 20
 21#--IronPython or something else?
 22is_silverlight = sys.platform == 'silverlight'
 23is_cli =         sys.platform == 'cli'
 24is_ironpython =  is_silverlight or is_cli
 25is_cpython    =  sys.platform == 'win32'
 26
 27if is_ironpython:
 28    #We'll use System, if available, to figure out more info on the test
 29    #environment later
 30    import System
 31    import clr
 32
 33
 34#--The bittedness of the Python implementation
 35is_cli32, is_cli64 = False, False
 36if is_ironpython: 
 37    is_cli32, is_cli64 = (System.IntPtr.Size == 4), (System.IntPtr.Size == 8)
 38
 39is_32, is_64 = is_cli32, is_cli64
 40if not is_ironpython:
 41    cpu = get_env_var("PROCESSOR_ARCHITECTURE")
 42    if cpu.lower()=="x86":
 43        is_32 = True
 44    elif cpu.lower()=="amd64":
 45        is_64 = True
 46    
 47
 48#--CLR version we're running on (if any)
 49is_orcas = False
 50if is_cli:
 51    is_orcas = len(clr.GetClrType(System.Reflection.Emit.DynamicMethod).GetConstructors()) == 8
 52
 53is_net40 = False
 54if is_cli:
 55    is_net40 = System.Environment.Version.Major==4
 56
 57is_dlr_in_ndp = False
 58if is_net40:
 59    try:
 60        clr.AddReference("Microsoft.Scripting.Core")
 61    except:
 62        is_dlr_in_ndp = True    
 63
 64#--Newlines
 65if is_ironpython:
 66    newline = System.Environment.NewLine
 67else:
 68    import os
 69    newline = os.linesep
 70
 71
 72#--Build flavor of Python being tested
 73is_debug = False
 74if is_cli:
 75    is_debug = sys.exec_prefix.lower().endswith("debug")
 76
 77
 78#--Are we using peverify to check that all IL generated is valid?
 79is_peverify_run = False
 80if is_cli:    
 81    is_peverify_run = is_debug and "-X:SaveAssemblies" in System.Environment.CommandLine    
 82
 83
 84#--Internal checkin system used for IronPython
 85is_snap = False
 86if not is_silverlight and get_env_var("THISISSNAP")!=None: 
 87    is_snap = True
 88
 89
 90#--We only run certain time consuming test cases in the stress lab
 91is_stress = False
 92if not is_silverlight and get_env_var("THISISSTRESS")!=None: 
 93    is_stress = True
 94
 95
 96#--Are we running tests under the Vista operating system?
 97is_vista = False
 98if not is_silverlight and get_env_var("IS_VISTA")=="1":
 99    is_vista = True
100
101is_win7 = False
102if is_ironpython:  #TODO - what about CPython?
103    is_win7 = System.Environment.OSVersion.Version.Major==6 and System.Environment.OSVersion.Version.Minor==1
104
105#------------------------------------------------------------------------------