pkg5testenv.py revision 3339
1715N/A# The contents of this file are subject to the terms of the 1715N/A# Common Development and Distribution License (the "License"). 1715N/A# You may not use this file except in compliance with the License. 1715N/A# See the License for the specific language governing permissions 1715N/A# and limitations under the License. 1715N/A# When distributing Covered Code, include this CDDL HEADER in each 1715N/A# If applicable, add the following below this CDDL HEADER, with the 1715N/A# fields enclosed by brackets "[]" replaced with your own identifying 1715N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3339N/A# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. 1715N/A """ Set up environment for doing testing. 1715N/A We set PYTHONPATH and PATH so that they reference the proto 1715N/A area, and clear packaging related environment variables 1715N/A (every variable prefixed with PKG_). 1715N/A path_to_proto should be a relative path indicating a path 1715N/A to proto area of the workspace. So, if your test case is 1715N/A This function looks at argv[0] to compute the ultimate 1715N/A path to the proto area; this is nice because you can then 1715N/A invoke test cases like normal commands; i.e.: 1971N/A If 'covdir' is provided, coverage will be started and the 1971N/A related coverage object returned. 3049N/A If 'system_test' is True, tests will run on live system. 3143N/A print(
"Unable to determine appropriate proto area location.")
3143N/A print(
"This is a porting problem.")
1715N/A # Figure out from where we're invoking the command 1715N/A # Clean up relative ../../, etc. out of path to proto 1715N/A # Because subprocesses must also source from the proto area, 1715N/A # we need to set PYTHONPATH in the environment as well as 3339N/A # Because some test cases will fail under Python 3 if the locale is set 3339N/A # to "C". A "C" locale supports only "ascii" characters, so esentially 3339N/A # if we want to test unicode characters, we need to use "utf-8" locale. 2692N/A # Proxy environment variables cause all kinds of problems, strip them 1715N/A # Use "keys"; otherwise we'll change dictionary size during iteration. 1715N/A # Tell package manager where its application data files live. 1715N/A # Save off the value for tempdir when we were invoked, since the 1715N/A # suite will subsequently modify tempdir to sandbox test cases.