Best Python code snippet using tox_python
SConstruct
Source:SConstruct
1# Copyright 2007 Google Inc. All Rights Reserved.2# Author: nigdsouza@google.com (Nigel D'souza)3"""GTags SConstruct file.4There are 4 main types of targets: libraries, binaries, tests, and run-tests.5Targets for each type are collected in separate lists. This allows easily6building types of targets by using the type as a target.7 Examples:8 'scons libs' will build all the libraries.9 'scons tests' will build all the tests.10Each type is also contained within it's own environment due to attribute11differences (such as pathing, flags, and builders).12All targets are aliased with their name so that, regardless of type, they can be13built with 'scons <target name>'. This is easier to remember than the default14name, which is the name of the target's output file.15All tests also have a run target defined. This is aliased with the name16'run:<test name>' so that they can be run with 'scons run:<test_name>'.17"""18import os19CC_TEST_FLAGS = ('-DTEST_TMP_DIR=\\"/tmp/gtags.test\\"'20 ' -DTEST_SRC_DIR=\\"%s\\"'% os.getcwd())21# Define library environment and build helper.22# The library environment also defines the CC_TEST_FLAGS for the test libraries23libs = []24lib_env = Environment()25def library(name, srcs):26 l = lib_env.Library(name, srcs)27 # Alias the library with it's name otherwise by default it gets the filename28 # of the generated library (e.g. 'filename.cc' gets 'libfilename.a')29 lib_env.Alias(name, l)30 libs.append(l)31 lib_env.Alias('libs', libs)32# Define binary envrionment and build helper.33bins = []34bin_env = Environment(LIBPATH = '.')35def binary(name, srcs, deps=[]):36 b = bin_env.Program(37 name, srcs,38 # Link the dependents twice so we don't have to worry about the order of39 # linked libraries.40 LIBS = deps + deps)41 bins.append(b)42 bin_env.Default(b)43 bin_env.Alias('bins', bins)44# Define test environment and build helper.45tests = []46TEST_LIBS = [ 'boost_unit_test_framework', 'tagsoptionparser' ]47test_env = Environment(48 LIBPATH = '.',49 CCFLAGS = CC_TEST_FLAGS,50 CPPPATH = '../..')51def test(name, srcs, deps=[]):52 t = test_env.Program(53 name, srcs,54 # The tests seem to be considerable tougher to link, so we'll cheat and55 # link the dependents thrice so we don't have to worry about the order of56 # linked libraries.57 LIBS = TEST_LIBS + deps + deps + deps)58 tests.append(t)59 test_env.Alias('tests', tests)60 # Create a run target for this test.61 rt = run_test_env.RunTest('run:' + name, t)62 run_tests.append(rt)63 run_test_env.AlwaysBuild(rt)64 run_test_env.Alias('runtests', run_tests)65# Define run test environment and builder.66def run_test(target, source, env):67 # Create the output directory.68 test_dir_name = 'test_out'69 if not os.path.exists(test_dir_name):70 os.mkdir(test_dir_name)71 # Create the temp directory.72 tmp_dir_name = '/tmp/gtags.test'73 if not os.path.exists(tmp_dir_name):74 os.mkdir(tmp_dir_name)75 # Run the test, storing the test output to a file.76 output_file = os.path.join(test_dir_name, source[0].name + '.out')77 cmd = str(source[0].abspath) + " >" + output_file + " 2>&1"78 # Display the test result.79 if os.system(cmd) == 0:80 print ' %-40s %s' % (source[0].name, 'PASSED')81 else:82 print ' %-40s %s' % (source[0].name, 'FAILED')83 print ' See test output in file: %s' % os.path.abspath(output_file)84run_tests = []85RUN_TEST_BUILDER = Builder(action = run_test)86run_test_env = Environment(BUILDERS = {'RunTest' : RUN_TEST_BUILDER })87# Libraries88# ==========================================================89library(name = 'datasource',90 srcs = 'datasource.cc')91library(name = 'filename',92 srcs = 'filename.cc')93library(name = 'filewatcher',94 srcs = 'filewatcher.cc')95library(name = 'filewatcherrequesthandler',96 srcs = 'filewatcherrequesthandler.cc')97library(name = 'indexagent',98 srcs = 'indexagent.cc')99library(name = 'mixer',100 srcs = 'gtagsmixer.cc')101library(name = 'mixerrequesthandler',102 srcs = 'mixerrequesthandler.cc')103library(name = 'mock_socket',104 srcs = 'mock_socket.cc')105library(name = 'pollable',106 srcs = 'pollable.cc')107library(name = 'pollserver',108 srcs = 'pollserver.cc')109library(name = 'settings',110 srcs = 'settings.cc')111library(name = 'sexpression',112 srcs = 'sexpression.cc')113library(name = 'sexpression_util',114 srcs = 'sexpression_util.cc')115library(name = 'socket',116 srcs = 'socket.cc')117library(name = 'socket_filewatcher_service',118 srcs = 'socket_filewatcher_service.cc')119library(name = 'socket_mixer_service',120 srcs = 'socket_mixer_service.cc')121library(name = 'socket_server',122 srcs = 'socket_server.cc')123library(name = 'socket_util',124 srcs = 'socket_util.cc')125library(name = 'socket_tags_service',126 srcs = 'socket_tags_service.cc')127library(name = 'socket_version_service',128 srcs = 'socket_version_service.cc')129library(name = 'strutil',130 srcs = 'strutil.cc')131library(name = 'symboltable',132 srcs = 'symboltable.cc')133library(name = 'tagsoptionparser',134 srcs = 'tagsoptionparser.cc')135library(name = 'tagsprofiler',136 srcs = 'tagsprofiler.cc')137library(name = 'tagsrequesthandler',138 srcs = 'tagsrequesthandler.cc')139library(name = 'tagstable',140 srcs = 'tagstable.cc')141# Applications142# ==========================================================143binary(name = 'gtags',144 srcs = 'gtags.cc',145 deps = [ 'filename',146 'socket_server',147 'symboltable',148 'sexpression',149 'strutil',150 'tagsoptionparser',151 'tagsprofiler',152 'tagsrequesthandler',153 'tagstable' ])154binary(name = 'gtagsmixer',155 srcs = 'gtagsmixermain.cc',156 deps = [ 'datasource',157 'filename',158 'filewatcher',159 'filewatcherrequesthandler',160 'indexagent',161 'mixer',162 'mixerrequesthandler',163 'pollable',164 'pollserver',165 'settings',166 'sexpression',167 'sexpression_util',168 'socket',169 'socket_filewatcher_service',170 'socket_mixer_service',171 'socket_version_service',172 'socket_tags_service',173 'strutil',174 'symboltable',175 'tagsoptionparser',176 'tagsrequesthandler',177 'tagstable',178 'pthread' ])179binary(name = 'gtagswatcher',180 srcs = 'gtagswatchermain.cc',181 deps = [ 'pollable',182 'pollserver',183 'sexpression',184 'socket',185 'socket_util',186 'socket_filewatcher_service',187 'strutil',188 'tagsoptionparser' ])189# Tests190# ==========================================================191test(name = 'callback_test',192 srcs = 'callback_test.cc'),193test(name = 'filename_test',194 srcs = 'filename_test.cc',195 deps = [ 'filename',196 'symboltable' ])197test(name = 'filewatcher_test',198 srcs = 'filewatcher_test.cc',199 deps = [ 'filewatcher' ])200test(name = 'filewatcherrequesthandler_test',201 srcs = 'filewatcherrequesthandler_test.cc',202 deps = [ 'filewatcherrequesthandler',203 'filename',204 'filewatcher',205 'strutil',206 'sexpression',207 'symboltable',208 'tagsrequesthandler',209 'tagstable' ])210test(name = 'indexagent_test',211 srcs = 'indexagent_test.cc',212 deps = [ 'indexagent',213 'filename',214 'sexpression',215 'strutil',216 'symboltable',217 'tagsrequesthandler',218 'tagstable' ])219test(name = 'mixer_test',220 srcs = 'gtagsmixer_test.cc',221 deps = [ 'mixer',222 'sexpression',223 'sexpression_util',224 'strutil' ])225test(name = 'mixerrequesthandler_test',226 srcs = 'mixerrequesthandler_test.cc',227 deps = [ 'mixerrequesthandler',228 'datasource',229 'filename',230 'mixer',231 'pollable',232 'pollserver',233 'socket',234 'socket_tags_service',235 'settings',236 'sexpression',237 'sexpression_util',238 'strutil',239 'symboltable',240 'tagstable',241 'tagsrequesthandler',242 'pollable' ])243test(name = 'mutex_test',244 srcs = 'mutex_test.cc')245test(name = 'pcqueue_test',246 srcs = 'pcqueue_test.cc')247test(name = 'pollable_test',248 srcs = 'pollable_test.cc',249 deps = [ 'pollable',250 'pollserver' ])251test(name = 'pollserver_test',252 srcs = 'pollserver_test.cc',253 deps = [ 'pollserver',254 'pollable' ])255test(name = 'semaphore_test',256 srcs = 'semaphore_test.cc')257test(name = 'settings_test',258 srcs = 'settings_test.cc',259 deps = [ 'settings',260 'datasource',261 'filename',262 'mixer',263 'pollable',264 'pollserver',265 'sexpression',266 'sexpression_util',267 'socket',268 'socket_tags_service',269 'strutil',270 'symboltable',271 'tagstable',272 'tagsrequesthandler' ])273test(name = 'sexpression_test',274 srcs = 'sexpression_test.cc',275 deps = [ 'sexpression',276 'datasource',277 'socket_tags_service',278 'strutil' ])279test(name = 'sexpression_util_test',280 srcs = 'sexpression_util_test.cc',281 deps = [ 'sexpression',282 'sexpression_util',283 'strutil' ])284test(name = 'socket_test',285 srcs = 'socket_test.cc',286 deps = [ 'socket',287 'mock_socket',288 'pollable',289 'pollserver',290 'socket_util' ])291test(name = 'socket_filewatcher_service_test',292 srcs = 'socket_filewatcher_service_test.cc',293 deps = [ 'socket_filewatcher_service',294 'filewatcherrequesthandler',295 'mock_socket',296 'pollable',297 'pollserver',298 'sexpression',299 'socket',300 'socket_util',301 'strutil' ])302test(name = 'socket_mixer_service_test',303 srcs = 'socket_mixer_service_test.cc',304 deps = [ 'socket_mixer_service',305 'datasource',306 'filename',307 'mixer',308 'mixerrequesthandler',309 'mock_socket',310 'pollable',311 'pollserver',312 'settings',313 'sexpression',314 'sexpression_util',315 'socket',316 'socket_tags_service',317 'socket_util',318 'strutil',319 'symboltable',320 'tagsrequesthandler',321 'tagstable' ])322test(name = 'socket_version_service_test',323 srcs = 'socket_version_service_test.cc',324 deps = [ 'socket_version_service',325 'mock_socket',326 'pollable',327 'pollserver',328 'socket',329 'socket_util',330 'strutil' ])331test(name = 'stl_util_test',332 srcs = 'stl_util_test.cc')333test(name = 'strutil_test',334 srcs = 'strutil_test.cc',335 deps = [ 'strutil' ])336test(name = 'symboltable_test',337 srcs = 'symboltable_test.cc',338 deps = [ 'symboltable' ])339test(name = 'tagsrequesthandler_test',340 srcs = 'tagsrequesthandler_test.cc',341 deps = [ 'tagsrequesthandler',342 'filename',343 'sexpression',344 'strutil',345 'symboltable',346 'tagstable' ])347test(name = 'tagstable_test',348 srcs = 'tagstable_test.cc',349 deps = [ 'tagstable',350 'filename',351 'sexpression',352 'strutil',353 'symboltable' ])354test(name = 'thread_test',...
test_package_parallel.py
Source:test_package_parallel.py
...44 t1_build_blocker.wait()45 return prev_build_package(config, session)46 m.setattr(tox.package, "build_package", build_package)47 prev_run_test_env = sequential.runtestenv48 def run_test_env(venv, redirect=False):49 t2_build_finished.wait()50 return prev_run_test_env(venv, redirect)51 m.setattr(sequential, "runtestenv", run_test_env)52 t1 = threading.Thread(target=invoke_tox_in_thread, args=("t1",))53 t1.start()54 t1_build_started.wait()55 with monkeypatch.context() as m:56 def build_package(config, session):57 t2_build_started.set()58 try:59 return prev_build_package(config, session)60 finally:61 t2_build_finished.set()62 m.setattr(tox.package, "build_package", build_package)63 t2 = threading.Thread(target=invoke_tox_in_thread, args=("t2",))64 t2.start()...
SConscript
Source:SConscript
1#******************************************************************2#3# Copyright 2016 Intel Corporation All Rights Reserved.4#5#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=6#7# Licensed under the Apache License, Version 2.0 (the "License");8# you may not use this file except in compliance with the License.9# You may obtain a copy of the License at10#11# http://www.apache.org/licenses/LICENSE-2.012#13# Unless required by applicable law or agreed to in writing, software14# distributed under the License is distributed on an "AS IS" BASIS,15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16# See the License for the specific language governing permissions and17# limitations under the License.18#19#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=20##21# ResourceClient Unit Test build script22##23import os24import sys25Import('env')26Import('upnpbundle_lib')27test_env = env.Clone()28######################################################################29#unit test setting30######################################################################31iotivity_base = env.get('IOTIVITY_BASE')32gtest_dir = env.get('IOTIVITY_BASE') + '/extlibs/gtest/googletest-release-1.7.0'33######################################################################34# Build flags35######################################################################36gtest = File(gtest_dir + '/lib/.libs/libgtest.a')37gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')38test_env.AppendUnique(39 CPPPATH = [40 iotivity_base + '/extlibs/hippomocks-master',41 iotivity_base + '/extlibs/gtest/googletest-release-1.7.0/include',42 '#/include',43 '#/src'44 ])45test_env.AppendUnique(CXXFLAGS = ['-std=c++11', '-Wall'])46oic_libs = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'rcs_container', 'rcs_client', 'rcs_server', 'rcs_common']47test_env.PrependUnique(LIBS = [48 gtest,49 gtest_main,50 oic_libs,51 'UpnpBundle'])52test_env.AppendUnique(LIBPATH = ['#/${BUILD_DIR}/bin'])53test_env.AppendUnique(LIBS = ['pthread'])54######################################################################55# Build Test56######################################################################57test_src = env.Glob('./*.cpp')58iotivity_upnp_bridge_test = test_env.Program('iotivity_upnp_bridge_test', test_src)59Alias("iotivity_upnp_bridge_test", iotivity_upnp_bridge_test)60iotivity_upnp_bridge_test_bin = env.Install('#/${BUILD_DIR}/bin', iotivity_upnp_bridge_test)61#env.AppendTarget('iotivity_upnp_bridge_test')62#if env.get('TEST') == '1':63# run_test_env = test_env.Clone()64# run_test_env.Append('BUILD_DIR', env.Dir('#/${BUILD_DIR}/bin').abspath)65# sys.path.append(iotivity_base)66# from tools.scons.RunTest import *...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!