Skip to content

Correctly generate TestEnv xplat #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ build_Tests()

echo "Starting the Managed Tests Build..."

#build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"

if [ $? -ne 0 ]; then
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
Expand Down
59 changes: 53 additions & 6 deletions tests/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,65 @@ def create_and_use_test_env(_os, env, func):
in runtest.sh.
"""

if _os == "Windows_NT":
complus_vars = defaultdict(lambda: None)

for key in env:
value = env[key]
if "complus" in key.lower():
complus_vars[key] = value

if len(complus_vars.keys()) > 0:
print "Found COMPlus variables in the current environment"
print

file_header = None

if _os == "Windows_NT":
file_header = \
"""@echo off
REM Temporary test env for test run.

"""
else:
file_header = \
"""# Temporary test env for test run.

"""

with tempfile.NamedTemporaryFile() as test_env:
with open(test_env.name, 'w') as file_handle:
for key in env:
file_handle.write("set %s=%s%s" % (key, value, os.linesep))
file_handle.write(file_header)

for key in complus_vars:
value = complus_vars[key]
command = None
if _os == "Windows_NT":
command = "set"
else:
command = "export"

print "Unset %s" % key
os.environ[key] = ""

file_handle.write("%s %s=%s%s" % (command, key, value, os.linesep))

contents = None
with open(test_env.name) as file_handle:
contents = file_handle.read()

print
print "TestEnv: %s" % test_env.name
print
print "Contents:"
print
print contents
print

func(test_env.name)

else:
func(None)


def get_environment():
""" Get all the COMPlus_* Environment variables

Expand Down Expand Up @@ -155,7 +202,7 @@ def call_msbuild(coreclr_repo_location,
command += msbuild_log_args

if host_os != "Windows_NT":
command = ["sh"] + command
command = ["bash"] + command

print " ".join(command)
subprocess.check_output(command)
Expand Down