Merge branch 'BS-23'

This commit is contained in:
rzaitov 2013-11-05 19:31:25 +04:00
commit 234dd0b546
9 changed files with 79 additions and 21 deletions

2
scripts/StagingSteps.txt Normal file
View File

@ -0,0 +1,2 @@
sh echo hello from '{@author}'
sh echo version: '{@version}'

View File

@ -20,6 +20,7 @@ class TestBuildConfigProvider(unittest.TestCase):
def test_unionConfig(self):
wr0 = {
'parent': None,
'name': None,
'dict': {
'key1': 'a',
'key2': 'b',
@ -29,6 +30,7 @@ class TestBuildConfigProvider(unittest.TestCase):
}
wr1 = {
'parent': wr0,
'name' : 'name0',
'dict':{
'key2': 'bb',
'key3': 'cc',
@ -39,6 +41,7 @@ class TestBuildConfigProvider(unittest.TestCase):
}
wr2 = {
'parent': wr1,
'name': 'name1',
'dict':{
'key3': 'ccc',
'key4': 'ddd',
@ -47,7 +50,8 @@ class TestBuildConfigProvider(unittest.TestCase):
}
}
config = self.provider.fetchConfigFromLeafWrapper(wr2)
configInfo = self.provider.fetchConfigInfoFromLeafWrapper(wr2)
config = configInfo[1]
expected = {
'key1': 'a',
'key2': 'bb',
@ -57,3 +61,36 @@ class TestBuildConfigProvider(unittest.TestCase):
'key6': 'fff'
}
self.assertDictEqual(expected, config)
def test_buildReadyNames(self):
config = {
'configs': 'ios, android, wp7'
}
names = self.provider.fetchBuildReadyConfigNames(config)
self.assertEqual(3, len(names))
self.assertTrue('ios' in names)
self.assertTrue('android' in names)
self.assertTrue('wp7' in names)
def test_getConfig(self):
rootConfig = {
'configs': 'ios, android',
'ios': {
},
'android': {
},
'wp7': {
}
}
configs = self.provider.getConfigs(rootConfig)
self.assertEqual(2, len(configs))

View File

@ -13,7 +13,10 @@ class TestMacroResolver(unittest.TestCase):
}
macroProcessor = MacroProcessor()
valueProvider = ValueProvider(config)
valueProvider = ValueProvider()
valueProvider.setConfig(config)
self.macroResolver = MacroResolver(macroProcessor, valueProvider)
def test_resolveLine(self):

View File

@ -11,9 +11,9 @@ class TestMacro(unittest.TestCase):
symbols = self.macroParser.getSymbols(line)
self.assertEqual(3, len(symbols))
self.assertTrue('this' in symbols)
self.assertTrue('my_macro' in symbols)
self.assertTrue('macro_with_numbers123' in symbols)
self.assertTrue('@this' in symbols)
self.assertTrue('@my_macro' in symbols)
self.assertTrue('@macro_with_numbers123' in symbols)
def test_getName(self):
line = '{@macro_name}'

View File

@ -7,7 +7,7 @@ from parser.InsideParser.InsideSetParser import InsideSetParser
class TestCsprojParser(unittest.TestCase):
def setUp(self):
value_provider = ValueProvider({})
value_provider = ValueProvider()
self.parser = InsideSetParser(value_provider, 'csproj')

View File

@ -8,7 +8,8 @@ class TestCase(unittest.TestCase):
'key1': 'value1',
'key2': 'value2'
}
self.__provider = ValueProvider(self.__config)
self.__provider = ValueProvider()
self.__provider.setConfig(self.__config)
def test_provideByLink(self):
value1 = self.__provider.getValueFor('@key1')

View File

@ -1,6 +1,7 @@
# global settings
build_tool = '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool'
version = '0.0.0'
configs = 'appstore, staging'
# ios platform settings
ios.steps = 'scripts/IosSteps.txt'
@ -8,14 +9,15 @@ ios.tf_api_token = '0e6925075d4fc10fed0e7bbf43fa6894_NjQ0OTI2MjAxMi0wOS0yNSAxMTo
ios.tf_team_token = 'c5c3cf7a6dae2bea4382dfbd181a2075_Mjc4ODkwMjAxMy0wOS0yOSAxNDowOTo1OC40Mzg5MTY'
# android platform settings
# android.steps = 'AndroidSteps.txt'
# android.steps = 'scripts/AndroidSteps.txt'
# config settings
ios.appstore.build_ready = 'true'
ios.appstore.app_name = 'CoolApp'
ios.appstore.sln_config = 'Release|iPhone'
ios.appstore.author = 'Rustam'
ios.appstore.version = '7.7.7'
#ios.staging.build_ready = 'true'
ios.staging.app_name = 'CoolApp staging'
ios.staging.steps = 'scripts/StagingSteps.txt'
ios.staging.author = 'Fedor'
ios.staging.version = '7.8.9'

View File

@ -41,8 +41,8 @@ class TaskRunner:
self.lineConveyor.addProcessor(macroResolver)
def run(self):
settings = self.settingsProvider.fetchSettings()
buildReadyConfigs = self.configsProvider.getConfigs(settings)
rawSettings = self.settingsProvider.fetchSettings()
buildReadyConfigs = self.configsProvider.getConfigs(rawSettings)
for bc in buildReadyConfigs:
self.valueProvider.setConfig(bc)

View File

@ -3,21 +3,34 @@ class BuildConfigProvider:
pass
def getConfigs(self, rootConfig):
buildReadyConfigNames = self.fetchBuildReadyConfigNames(rootConfig)
leafs = []
self.traverseDict(None, rootConfig, leafs)
self.traverseDict(None, None, rootConfig, leafs)
configs = []
for l in leafs:
config = self.fetchConfigFromLeafWrapper(l)
if config.get('build_ready', 'false') == 'true':
configInfo = self.fetchConfigInfoFromLeafWrapper(l)
name = configInfo[0]
config = configInfo[1]
if name in buildReadyConfigNames:
configs.append(config)
return configs
def traverseDict(self, parent, dictForTraverse, leafs):
def fetchBuildReadyConfigNames(self, rootConfig):
value = rootConfig['configs']
names = value.split(',')
names = [name.strip(' ') for name in names]
return names
def traverseDict(self, parent, key, dictForTraverse, leafs):
wrapper = {
'parent' : parent,
'dict' : dictForTraverse
'parent': parent,
'dict': dictForTraverse,
'name': key
}
isLeaf = True
@ -26,12 +39,12 @@ class BuildConfigProvider:
if type(value) is dict:
isLeaf = False
self.traverseDict(wrapper, value, leafs)
self.traverseDict(wrapper, key, value, leafs)
if isLeaf:
leafs.append(wrapper)
def fetchConfigFromLeafWrapper(self, leafWrapper):
def fetchConfigInfoFromLeafWrapper(self, leafWrapper):
ancestors = self.getAncestorsFor(leafWrapper)
unionConf = {}
@ -42,7 +55,7 @@ class BuildConfigProvider:
if type(value) is str:
unionConf[k] = value
return unionConf
return leafWrapper['name'], unionConf
def getAncestorsFor(self, leaf):
ancestors = [leaf]