0
|
1 |
# *-* coding: utf-8 *-*
|
|
2 |
#
|
|
3 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
# All rights reserved.
|
|
5 |
# This component and the accompanying materials are made available
|
|
6 |
# under the terms of "Eclipse Public License v1.0"
|
|
7 |
# which accompanies this distribution, and is available
|
|
8 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
#
|
|
10 |
# Initial Contributors:
|
|
11 |
# Nokia Corporation - initial contribution.
|
|
12 |
#
|
|
13 |
# Contributors:
|
|
14 |
#
|
|
15 |
# Description:
|
|
16 |
#
|
|
17 |
##
|
|
18 |
# @author Lasse Salo
|
|
19 |
|
|
20 |
import sys, os, shutil, unittest
|
|
21 |
import __init__
|
|
22 |
from testautomation.base_testcase import BaseTestCase
|
|
23 |
from testautomation import zip_dir
|
|
24 |
|
|
25 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
26 |
|
|
27 |
if sys.platform == "win32":
|
|
28 |
CONE_SCRIPT = "cone.cmd"
|
|
29 |
else:
|
|
30 |
CONE_SCRIPT = "cone.sh"
|
|
31 |
|
|
32 |
def get_cmd(action='generate'):
|
|
33 |
"""Return the command used to run the ConE sub-action"""
|
|
34 |
if 'CONE_PATH' in os.environ:
|
|
35 |
CONE_CMD = os.path.join(os.environ['CONE_PATH'], CONE_SCRIPT)
|
|
36 |
if not os.path.exists(CONE_CMD):
|
|
37 |
raise RuntimeError("'%s' does not exist!" % CONE_CMD)
|
|
38 |
return '"%s" %s' % (CONE_CMD, action)
|
|
39 |
else:
|
|
40 |
SOURCE_ROOT = os.path.normpath(os.path.join(ROOT_PATH, '../../..'))
|
|
41 |
assert os.path.split(SOURCE_ROOT)[1] == 'source'
|
|
42 |
cmd = 'python "%s" %s' % (os.path.normpath(os.path.join(SOURCE_ROOT, 'scripts/cone_tool.py')), action)
|
|
43 |
return cmd
|
|
44 |
|
|
45 |
class TestCommonGenerateAllImplsOnLastLayer(BaseTestCase):
|
|
46 |
|
|
47 |
def _prepare_workdir(self, workdir):
|
|
48 |
workdir = os.path.join(ROOT_PATH, workdir)
|
|
49 |
self.recreate_dir(workdir)
|
|
50 |
|
|
51 |
# Any needed extra preparation can be done here
|
|
52 |
|
|
53 |
return workdir
|
|
54 |
|
|
55 |
def test_generate_all_impls_on_last_layer_on_file_storage(self):
|
|
56 |
project_dir = os.path.join(ROOT_PATH, "testdata/generate/project")
|
|
57 |
self.assert_exists_and_contains_something(project_dir)
|
|
58 |
self._run_test_generate_all_impls_on_last_layer('temp/gen_ll1', project_dir)
|
|
59 |
|
|
60 |
def test_generate_all_impls_on_last_layer_on_zip_storage(self):
|
|
61 |
project_dir = os.path.join(ROOT_PATH, "testdata/generate/project")
|
|
62 |
self.assert_exists_and_contains_something(project_dir)
|
|
63 |
|
|
64 |
project_zip = os.path.join(ROOT_PATH, "temp/generation_test_project.zip")
|
|
65 |
self.remove_if_exists(project_zip)
|
|
66 |
zip_dir.zip_dir(project_dir, project_zip, [zip_dir.SVN_IGNORE_PATTERN])
|
|
67 |
self.assert_exists_and_contains_something(project_zip)
|
|
68 |
|
|
69 |
self._run_test_generate_all_impls_on_last_layer('temp/gen_ll2', project_zip)
|
|
70 |
|
|
71 |
def _run_test_generate_all_impls_on_last_layer(self, workdir, project):
|
|
72 |
# Create a temp workdir and go there to run the test
|
|
73 |
orig_workdir = os.getcwd()
|
|
74 |
workdir = self._prepare_workdir(workdir)
|
|
75 |
os.chdir(workdir)
|
|
76 |
|
|
77 |
try:
|
|
78 |
cmd = '%s -p "%s" --output output --layer -1 --add-setting-file imaker_variantdir.cfg' % (get_cmd(), project)
|
|
79 |
self.run_command(cmd)
|
|
80 |
|
|
81 |
EXPECTED_DIR = os.path.join(ROOT_PATH, "testdata/generate/expected")
|
|
82 |
self.assert_dir_contents_equal('output', EXPECTED_DIR, ['.svn'])
|
|
83 |
finally:
|
|
84 |
os.chdir(orig_workdir)
|
|
85 |
|
|
86 |
if __name__ == '__main__':
|
|
87 |
unittest.main()
|