Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Side by Side Diff: appengine/swarming/swarming_bot/test_env_bot.py

Issue 2751863003: Ensure the packed version of protobuf is used on bot tests. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 7
8 8
9 # swarming_bot/ 9 # swarming_bot/
10 BOT_DIR = os.path.dirname(os.path.realpath(os.path.abspath(__file__))) 10 BOT_DIR = os.path.dirname(os.path.realpath(os.path.abspath(__file__)))
(...skipping 18 matching lines...) Expand all
29 if '\n' in link: 29 if '\n' in link:
30 continue 30 continue
31 dest = os.path.normpath(os.path.join(root, link)) 31 dest = os.path.normpath(os.path.join(root, link))
32 # This is not exactly right but close enough. 32 # This is not exactly right but close enough.
33 sys.path.insert(0, os.path.dirname(dest)) 33 sys.path.insert(0, os.path.dirname(dest))
34 34
35 35
36 def setup_test_env(): 36 def setup_test_env():
37 """Sets up the environment for bot tests.""" 37 """Sets up the environment for bot tests."""
38 init_symlinks(BOT_DIR) 38 init_symlinks(BOT_DIR)
39 client_tests = os.path.normpath( 39 client = os.path.normpath(os.path.join(BOT_DIR, '..', '..', '..', 'client'))
40 os.path.join(BOT_DIR, '..', '..', '..', 'client', 'tests')) 40 client_tests = os.path.join(client, 'tests')
41 sys.path.insert(0, client_tests) 41 sys.path.insert(0, client_tests)
42 42
43 tp = os.path.join(BOT_DIR, 'third_party') 43 tp = os.path.join(BOT_DIR, 'third_party')
44 if sys.platform == 'win32': 44 if sys.platform == 'win32':
45 # third_party is a symlink. 45 # third_party is a symlink.
46 with open(tp, 'rb') as f: 46 with open(tp, 'rb') as f:
47 tp = os.path.join(BOT_DIR, f.read()) 47 tp = os.path.join(BOT_DIR, f.read())
48 sys.path.insert(0, tp) 48 sys.path.insert(0, tp)
49 49
50 # libusb1 expects to be directly in sys.path. 50 # libusb1 expects to be directly in sys.path.
51 sys.path.insert(0, os.path.join(BOT_DIR, 'python_libusb1')) 51 sys.path.insert(0, os.path.join(BOT_DIR, 'python_libusb1'))
52 52
53 # For python-rsa. 53 # For python-rsa.
54 sys.path.insert(0, os.path.join(tp, 'rsa')) 54 sys.path.insert(0, os.path.join(tp, 'rsa'))
55 sys.path.insert(0, os.path.join(tp, 'pyasn1')) 55 sys.path.insert(0, os.path.join(tp, 'pyasn1'))
56
57 # Protobuf is now used in the bot itself.
58 # See fix_protobuf_package() in appengine/components/components/utils.py
59 # but until this code, the version under client is used.
60 if 'google' in sys.modules:
61 # It may be in lib/python2.7/site-packages/google, take not chance and flush
62 # it out.
63 del sys.modules['google']
64 # This should import client/third_party/google
65 import google
66 protobuf_pkg = os.path.join(client, 'third_party', 'protobuf', 'google')
dsansome 2017/03/17 01:54:55 This should just be os.path.join(client, 'third_pa
M-A Ruel 2017/03/24 20:12:52 Done.
67 if protobuf_pkg not in google.__path__:
68 google.__path__.append(protobuf_pkg)
dsansome 2017/03/17 01:54:55 This needs to be insert(0, ...)
M-A Ruel 2017/03/24 20:12:52 Done.
69 six_path = os.path.join(client, 'third_party', 'six')
70 if six_path not in sys.path:
71 sys.path.insert(0, six_path)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698