diff --git a/BuildSample/BuildSample/CoolApp.csproj b/BuildSample/BuildSample/CoolApp.csproj index cca0400..1a17219 100644 --- a/BuildSample/BuildSample/CoolApp.csproj +++ b/BuildSample/BuildSample/CoolApp.csproj @@ -53,7 +53,7 @@ full true - bin\iPhone\Release + Output prompt 4 iPhone Developer: Рустам Заитов (CTL85FZX6K) diff --git a/scripts/IosSetupSteps.txt b/scripts/IosSetupSteps.txt index faf4972..66b0c12 100644 --- a/scripts/IosSetupSteps.txt +++ b/scripts/IosSetupSteps.txt @@ -3,7 +3,7 @@ create backup for 'BuildSample' inside 'BuildSample/BuildSample.sln' remove NotCompileApp project -inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' +inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' for '{@sln_config}' inside 'BuildSample/BuildSample/Info.plist' set CFBundleVersion to '{@version}' inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to 'CoolApp' diff --git a/scripts/MANIFEST b/scripts/MANIFEST index 494e951..7a23ba5 100644 --- a/scripts/MANIFEST +++ b/scripts/MANIFEST @@ -51,6 +51,7 @@ TouchinBuild/parsers/__init__.py TouchinBuild/parsers/CopyParser/CopyArguments.py TouchinBuild/parsers/CopyParser/CopyLineParser.py TouchinBuild/parsers/CopyParser/__init__.py +TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py TouchinBuild/parsers/InsideParser/InsideRemoveParser.py TouchinBuild/parsers/InsideParser/InsideSetParser.py TouchinBuild/parsers/InsideParser/__init__.py diff --git a/scripts/TouchinBuild/CommandBuilders/PatchCsprojCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/PatchCsprojCommandBuilder.py index 190f17e..5c04b90 100644 --- a/scripts/TouchinBuild/CommandBuilders/PatchCsprojCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/PatchCsprojCommandBuilder.py @@ -1,26 +1,21 @@ from commands.PatchCsprojCommand import PatchCsprojCommand -from parsers.InsideParser.InsideSetParser import InsideSetParser +from parsers.InsideParser.InsideCsprojSetParser import InsideCsprojSetParser class PatchCsprojCommandBuilder: - def __init__(self, config, valueProvider): - assert config is not None - assert valueProvider is not None - - self.__config = config - self.__valueProvider = valueProvider + def __init__(self): + pass def getCommandFor(self, line): assert line is not None - parser = InsideSetParser(self.__valueProvider, 'csproj') + parser = self.getParser() result = parser.parseLine(line) csprojPath = result[0] key = result[1] - value = self.__valueProvider.getValueFor(result[2]) - - slnConfig = self.__config['sln_config'] + value = result[2] + slnConfig = result[3] command = PatchCsprojCommand(csprojPath, key, value, slnConfig) return command @@ -28,8 +23,10 @@ class PatchCsprojCommandBuilder: def isPatchCsproj(self, line): assert line is not None - parser = InsideSetParser(self.__valueProvider, 'csproj') + parser = self.getParser() isValid = parser.isValidLine(line) return isValid + def getParser(self): + return InsideCsprojSetParser('csproj') \ No newline at end of file diff --git a/scripts/TouchinBuild/CommandBuilders/PatchInfoplistCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/PatchInfoplistCommandBuilder.py index 75af291..7c56d72 100644 --- a/scripts/TouchinBuild/CommandBuilders/PatchInfoplistCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/PatchInfoplistCommandBuilder.py @@ -28,6 +28,6 @@ class PatchInfoplistCommandBuilder: return command def __createParser(self): - parser = InsideSetParser(self.__valueProvider, 'plist') + parser = InsideSetParser('plist') return parser diff --git a/scripts/TouchinBuild/Core/StepsRunner.py b/scripts/TouchinBuild/Core/StepsRunner.py index d115eef..4883959 100644 --- a/scripts/TouchinBuild/Core/StepsRunner.py +++ b/scripts/TouchinBuild/Core/StepsRunner.py @@ -27,7 +27,7 @@ class StepsRunner: self.restoreFromBackupBuilder = RestoreBackupCommandBuilder() self.deleteBackupBuilder = DeleteBackupCommandBuilder() self.createDirs = MakeDirsCommandBuilder() - self.patchCsproj = PatchCsprojCommandBuilder(config, self.valueProvider) + self.patchCsproj = PatchCsprojCommandBuilder() self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider) self.copyBuilder = CopyCommandBuilder() self.testflightBuilder = TestflightCommandBuilder() diff --git a/scripts/TouchinBuild/Tests/ManualTests/csproj_test.py b/scripts/TouchinBuild/Tests/ManualTests/csproj_test.py index c307d0a..6e5a94d 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/csproj_test.py +++ b/scripts/TouchinBuild/Tests/ManualTests/csproj_test.py @@ -1,11 +1,8 @@ from CommandBuilders.PatchCsprojCommandBuilder import PatchCsprojCommandBuilder from commands.ValueProvider import ValueProvider -config = {'sln_config' : 'Release|iPhone'} -line = "inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output'" +line = "inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' for 'Release|iPhone'" -value_provider = ValueProvider(config) - -builder = PatchCsprojCommandBuilder(config, value_provider) +builder = PatchCsprojCommandBuilder() command = builder.getCommandFor(line) command.execute() \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/ProjectParser/test_projectParser.py b/scripts/TouchinBuild/Tests/UnitTests/ProjectParser/test_projectParser.py index 9456623..c6b9a07 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/ProjectParser/test_projectParser.py +++ b/scripts/TouchinBuild/Tests/UnitTests/ProjectParser/test_projectParser.py @@ -1,18 +1,16 @@ # -*- coding: utf-8 -*- import unittest -from commands.ValueProvider import ValueProvider -from parsers.InsideParser.InsideSetParser import InsideSetParser +from parsers.InsideParser.InsideCsprojSetParser import InsideCsprojSetParser class TestCsprojParser(unittest.TestCase): def setUp(self): - value_provider = ValueProvider() - self.parser = InsideSetParser(value_provider, 'csproj') + self.parser = InsideCsprojSetParser('csproj') def test_isValid(self): - line = "inside 'CoolApp.csproj' set KEY to 'VALUE'" + line = "inside 'CoolApp.csproj' set KEY to 'VALUE' for 'Sln|Config'" isValid = self.parser.isValidLine(line) self.assertEqual(True, isValid) @@ -24,9 +22,10 @@ class TestCsprojParser(unittest.TestCase): self.assertEqual(False, isValid) def test_parse(self): - line = "inside 'Dir/../Some Folder/CoolApp.csproj' set OutputPath to 'Output'" + line = "inside 'Dir/../Some Folder/CoolApp.csproj' set OutputPath to 'Output' for 'Release|iPhone'" result = self.parser.parseLine(line) self.assertEqual('Dir/../Some Folder/CoolApp.csproj', result[0]) self.assertEqual('OutputPath', result[1]) - self.assertEqual('Output', result[2]) \ No newline at end of file + self.assertEqual('Output', result[2]) + self.assertEqual('Release|iPhone', result[3]) \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/readme.txt b/scripts/TouchinBuild/Tests/UnitTests/readme.txt index 8ee3a1e..034f363 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/readme.txt +++ b/scripts/TouchinBuild/Tests/UnitTests/readme.txt @@ -1,3 +1,5 @@ +тесты нужно запускать из папки TouchinBuild + Запуск всех тестов python -m unittest discover -s Tests/UnitTests/ diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py new file mode 100644 index 0000000..2dcf2e9 --- /dev/null +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py @@ -0,0 +1,48 @@ +import re + +from parsers.LineParser import LineParser + + +class InsideCsprojSetParser(LineParser): + def __init__(self, fileExt): + LineParser.__init__(self) + + self.__extension = fileExt + + def parseLine(self, line): + assert line is not None + + matchInfo = self.getMatchInfo(line) + match = matchInfo[0] + regexpSource = matchInfo[1] + self._guardMatch(match, line, regexpSource) + + filePath = match.group('file') + key = match.group('key') + value = match.group('value') + slnConfig = match.group('config') + + return filePath, key, value, slnConfig + + def getMatchInfo(self, line): + assert line is not None + + filePathRegexp = r"'(?P[./ a-zA-Z]+\.{0})'".format(self.__extension) + keyRegexp = r'(?P[a-zA-Z]+)' + valueRegexp = r"'(?P[^']+)'" + slnConfigRegexp = r"'(?P[a-zA-Z|]+)'$" + + regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + \ + self.keywordToken('to') + valueRegexp + self.keywordToken('for') + slnConfigRegexp + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + return match, regexpSource + + def isValidLine(self, line): + assert line is not None + + matchInfo = self.getMatchInfo(line) + match = matchInfo[0] + + return match is not None \ No newline at end of file diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py index cef95f6..7269940 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py @@ -4,24 +4,16 @@ from parsers.LineParser import LineParser class InsideSetParser(LineParser): - def __init__(self, value_provider, fileExt): + def __init__(self, fileExt): LineParser.__init__(self) - assert value_provider is not None - - self.__value_provider = value_provider self.__extension = fileExt def parseLine(self, line): assert line is not None - filePathRegexp = r"'(?P[./ a-zA-Z]+\.{0})'".format(self.__extension) - keyRegexp = r'(?P[a-zA-Z]+)' - valueRegexp = r"'(?P[^']+)'" - - regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + self.keywordToken('to') + valueRegexp - regexp = re.compile(regexpSource, re.UNICODE) - - match = regexp.match(line) + matchInfo = self.getMatchInfo(line) + match = matchInfo[0] + regexpSource = matchInfo[1] self._guardMatch(match, line, regexpSource) filePath = match.group('file') @@ -30,9 +22,24 @@ class InsideSetParser(LineParser): return filePath, key, value - def isValidLine(self, line): - regexpSrc = r"inside\s+'[./ a-zA-Z]+\.{0}'\s+set".format(self.__extension) - regexp = re.compile(regexpSrc, re.UNICODE) + def getMatchInfo(self, line): + assert line is not None + + filePathRegexp = r"'(?P[./ a-zA-Z]+\.{0})'".format(self.__extension) + keyRegexp = r'(?P[a-zA-Z]+)' + valueRegexp = r"'(?P[^']+)'$" + + regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + \ + self.keywordToken('to') + valueRegexp + regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) + + return match, regexpSource + + def isValidLine(self, line): + assert line is not None + + matchInfo = self.getMatchInfo(line) + match = matchInfo[0] return match is not None \ No newline at end of file diff --git a/scripts/TouchinBuild/run_manual_tests.py b/scripts/TouchinBuild/run_manual_tests.py index 48d8410..3e21544 100644 --- a/scripts/TouchinBuild/run_manual_tests.py +++ b/scripts/TouchinBuild/run_manual_tests.py @@ -2,11 +2,11 @@ import os scriptFilePath = os.path.abspath(__file__) scriptDir = os.path.dirname(scriptFilePath) -baseDir = os.path.join(scriptDir, os.pardir) +baseDir = os.path.join(scriptDir, os.pardir, os.pardir) os.chdir(baseDir) -#import ManualTests.csproj_test +import Tests.ManualTests.csproj_test #import ManualTests.info_plist_test #import ManualTests.copy_test #import ManualTests.create_backup_test @@ -19,5 +19,4 @@ os.chdir(baseDir) #import ManualTests.infoplist_test #import ManualTests.clean_test #import Tests.ManualTests.testflight_test - -import Tests.ManualTests.install_profile +#import Tests.ManualTests.install_profile