0
|
1 |
# Copyright (c) 2009 Nokia Corporation
|
|
2 |
#
|
|
3 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
# you may not use this file except in compliance with the License.
|
|
5 |
# You may obtain a copy of the License at
|
|
6 |
#
|
|
7 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
#
|
|
9 |
# Unless required by applicable law or agreed to in writing, software
|
|
10 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
# See the License for the specific language governing permissions and
|
|
13 |
# limitations under the License.
|
|
14 |
|
|
15 |
import os
|
|
16 |
import shutil
|
|
17 |
|
|
18 |
sis_list = " "
|
|
19 |
topdir = "..\\..\\.."
|
|
20 |
testapp_sis = ""
|
|
21 |
my_dirs = []
|
|
22 |
|
|
23 |
|
|
24 |
def parse_ensymble_options(test_file, fp):
|
|
25 |
# Find the ensymble options associated with test script, in options.txt
|
|
26 |
line = fp.readline().strip('\n')
|
|
27 |
while line:
|
|
28 |
test_script, ensymble_options = line.split(':')
|
|
29 |
if test_script + ".py" == test_file:
|
|
30 |
return ensymble_options
|
|
31 |
line = fp.readline().strip('\n')
|
|
32 |
return ""
|
|
33 |
|
|
34 |
|
|
35 |
def copy_modules():
|
|
36 |
# Copy the modules created for testing to module-repo folder
|
|
37 |
for dirname in os.listdir('..\\test_package'):
|
|
38 |
if dirname not in ["test_scripts", ".svn"]:
|
|
39 |
my_dirs.append(dirname)
|
|
40 |
shutil.copytree('..\\test_package\\' + dirname, \
|
|
41 |
'module-repo\\dev-modules\\' + dirname + "\\" + dirname)
|
|
42 |
|
|
43 |
for testapp in os.listdir(topdir + '\\build\\test\\'):
|
|
44 |
# Search for testapp sis white choco variant
|
|
45 |
if testapp.startswith('testapp_') and testapp.endswith('_white_choco.sis'):
|
|
46 |
testapp_sis = testapp
|
|
47 |
|
|
48 |
if testapp_sis:
|
|
49 |
# Create and embed the test sis only if testapp is present
|
|
50 |
copy_modules()
|
|
51 |
for filename in os.listdir('..\\test_package\\test_scripts'):
|
|
52 |
if filename != 'options.txt' and filename != '.svn':
|
|
53 |
fp = open('..\\test_package\\test_scripts\\options.txt', 'r')
|
|
54 |
ensymble_options = parse_ensymble_options(filename, fp)
|
|
55 |
fp.close()
|
|
56 |
os.system('python ensymble.py py2sis ' + \
|
|
57 |
ensymble_options + ' ..\\test_package\\test_scripts' + \
|
|
58 |
'\\' + filename)
|
|
59 |
sis_list = sis_list + \
|
|
60 |
filename.split('.')[0] + '_v1_0_0.sis '
|
|
61 |
os.system('python ensymble.py mergesis --cert=' + \
|
|
62 |
topdir + '\\..\\keys\\pythonteam_pem.crt --privkey=' + \
|
|
63 |
topdir + '\\..\\\keys\\pythonteam.key --passphrase=12345 ' + \
|
|
64 |
topdir + '\\build\\test\\' + testapp_sis + sis_list + testapp_sis)
|
|
65 |
|
|
66 |
# Move the merged testapp sis to the build artifacts-test directory and
|
|
67 |
# remove the generated test sis and clean up the modules copied to module-repo
|
|
68 |
# folder
|
|
69 |
shutil.move(testapp_sis, topdir + '\\build\\test\\' + testapp_sis)
|
|
70 |
for sis_files in os.listdir(os.getcwd()):
|
|
71 |
if sis_files.startswith('test_') and sis_files.endswith('.sis'):
|
|
72 |
os.remove(sis_files)
|
|
73 |
for _dir in my_dirs:
|
|
74 |
os.system('rmdir /S/Q ' + 'module-repo\\dev-modules\\' + _dir)
|