Merge branch 'BS-22'

This commit is contained in:
rzaitov 2013-11-05 16:37:54 +04:00
commit 0de5e3a3a4
8 changed files with 85 additions and 2 deletions

View File

@ -0,0 +1,21 @@
from commands.CopyCommand import CopyCommand
from parser.InstallProfileParser import InstallProfileParser
class InstallProfileCommandBuilder:
def __init__(self):
pass
def isInstallProfile(self, line):
assert line is not None
return line.startswith('install profile')
def getCommandFor(self, line):
assert line is not None
parser = InstallProfileParser()
cpArgs = parser.parseLine(line)
command = CopyCommand(cpArgs)
return command

View File

@ -2,6 +2,7 @@ from CommandBuilders.CleanBuildCommandBuilder import CleanBuildCommandBuilder
from CommandBuilders.CopyCommandBuilder import CopyCommandBuilder
from CommandBuilders.CreateBackupCommandBuilder import CreateBackupCommandBuilder
from CommandBuilders.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder
from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBuilder
from CommandBuilders.MakeDirsCommandBuilder import MakeDirsCommandBuilder
from CommandBuilders.PatchCsprojCommandBuilder import PatchCsprojCommandBuilder
from CommandBuilders.PatchInfoplistCommandBuilder import PatchInfoplistCommandBuilder
@ -30,6 +31,7 @@ class StepsRunner:
self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider)
self.copyBuilder = CopyCommandBuilder()
self.testflightBuilder = TestflightCommandBuilder()
self.installProfileBuilder = InstallProfileCommandBuilder()
buildUtilPath = config['build_tool']
self.cleanBuilder = CleanBuildCommandBuilder(buildUtilPath, 'clean')
@ -72,6 +74,8 @@ class StepsRunner:
cmd =self.deleteBackupBuilder.getCommandFor(line)
elif self.testflightBuilder.isTestflight(line):
cmd = self.testflightBuilder.getCommandFor(line)
elif self.installProfileBuilder.isInstallProfile(line):
cmd = self.installProfileBuilder.getCommandFor(line)
else:
msg = "unrecognised step. Line: '{0}'".format(line)
raise Exception(msg)

View File

@ -10,7 +10,7 @@ inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output'
inside 'BuildSample/BuildSample/Info.plist' set CFBundleVersion to '{@version}'
inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to 'CoolApp'
copy 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision' to '~/Library/MobileDevice/Provisioning Profiles/BuildScript.mobileprovision'
install profile 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision'
clean 'BuildSample/BuildSample.sln' for '{@sln_config}'
build 'BuildSample/BuildSample.sln' for '{@sln_config}'

View File

@ -0,0 +1,8 @@
from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBuilder
line = "install profile 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision'"
builder = InstallProfileCommandBuilder()
command = builder.getCommandFor(line)
command.execute()

View File

@ -0,0 +1 @@
__author__ = 'rzaitov'

View File

@ -0,0 +1,14 @@
import unittest
from parser.InstallProfileParser import InstallProfileParser
class TestInstallProfile(unittest.TestCase):
def setUp(self):
self.parser = InstallProfileParser()
def test_parse(self):
line = "install profile 'Path/To/Profile.mobileprovision'"
copyArgs = self.parser.parseLine(line)
self.assertEqual('Path/To/Profile.mobileprovision', copyArgs.source)
self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/Profile.mobileprovision', copyArgs.target)

View File

@ -0,0 +1,34 @@
import re
import os
from parser.CopyParser.CopyArguments import CopyArguments
from parser.LineParser import LineParser
class InstallProfileParser(LineParser):
def __init__(self):
LineParser.__init__(self)
self.__copyArguments = CopyArguments()
self.__profileStorageDir = '~/Library/MobileDevice/Provisioning Profiles/'
def parseLine(self, line):
assert line is not None
profilePathRegexp = r"'(?P<path>[^']+)'$"
regexpSource = self.startsWith('install') + self.than('profile') + profilePathRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)
self._guardMatch(match, line, regexpSource)
srcPath = match.group('path')
dstPath = self.getDestinationPath(srcPath)
self.__copyArguments.setArguments(srcPath, dstPath)
return self.__copyArguments
def getDestinationPath(self, sourcePath):
profileFileName = os.path.basename(sourcePath)
destination = os.path.join(self.__profileStorageDir, profileFileName)
return destination

View File

@ -18,5 +18,6 @@ os.chdir(baseDir)
#import ManualTests.remove_project
#import ManualTests.infoplist_test
#import ManualTests.clean_test
import Tests.ManualTests.testflight_test
#import Tests.ManualTests.testflight_test
import Tests.ManualTests.install_profile