Merge branch 'BS-25'
This commit is contained in:
commit
96adf3834f
|
|
@ -0,0 +1,9 @@
|
|||
class FileContentProvider:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def fetchContent(self, path):
|
||||
file = open(path)
|
||||
content = file.read()
|
||||
|
||||
return content
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
class CommentRemover:
|
||||
def processLine(self, line):
|
||||
def processText(self, line):
|
||||
assert line is not None
|
||||
|
||||
newLine = line
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class MacroResolver:
|
|||
self.macroProcessor = macroProcessor
|
||||
self.valueProvider = valueProvider
|
||||
|
||||
def processLine(self, line):
|
||||
def processText(self, line):
|
||||
assert line is not None
|
||||
|
||||
symbols = self.macroProcessor.getSymbols(line)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class Stripper:
|
||||
def processLine(self, line):
|
||||
def processText(self, line):
|
||||
assert line is not None
|
||||
|
||||
return line.strip(' \t\n\r')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class LineConveyor:
|
||||
class TextConveyorPreprocessor:
|
||||
def __init__(self):
|
||||
self.processors = []
|
||||
|
||||
|
|
@ -7,10 +7,10 @@ class LineConveyor:
|
|||
|
||||
self.processors.append(processor)
|
||||
|
||||
def processLine(self, line):
|
||||
assert line is not None
|
||||
def processText(self, text):
|
||||
assert text is not None
|
||||
|
||||
for processor in self.processors:
|
||||
line = processor.processLine(line)
|
||||
text = processor.processText(text)
|
||||
|
||||
return line
|
||||
return text
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
class TextInclude:
|
||||
def __init__(self, includeProcessor, contentProvider):
|
||||
assert includeProcessor is not None
|
||||
assert contentProvider is not None
|
||||
|
||||
self.includeProcessor = includeProcessor
|
||||
self.contentProvider = contentProvider
|
||||
|
||||
def processText(self, text):
|
||||
assert text is not None
|
||||
includesInfo = self.includeProcessor.getIncludesInfo(text)
|
||||
|
||||
for info in includesInfo:
|
||||
includeStatement = info[0]
|
||||
path = info[1]
|
||||
|
||||
content = self.contentProvider.fetchContent(path)
|
||||
text = text.replace(includeStatement, content)
|
||||
|
||||
return text
|
||||
|
|
@ -42,7 +42,7 @@ class StepsRunner:
|
|||
|
||||
lines = content.splitlines()
|
||||
for line in lines:
|
||||
processedLine = self.lineConveyor.processLine(line)
|
||||
processedLine = self.lineConveyor.processText(line)
|
||||
|
||||
if len(processedLine) == 0:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
restore from backup
|
||||
create backup for 'BuildSample'
|
||||
|
||||
inside 'BuildSample/BuildSample.sln' remove NotCompileApp project
|
||||
|
||||
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'
|
||||
|
||||
install profile 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision'
|
||||
|
|
@ -1,16 +1,7 @@
|
|||
sh echo hello from '{@author}'
|
||||
sh echo version: '{@version}'
|
||||
|
||||
restore from backup
|
||||
create backup for 'BuildSample'
|
||||
|
||||
inside 'BuildSample/BuildSample.sln' remove NotCompileApp project
|
||||
|
||||
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'
|
||||
|
||||
install profile 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision'
|
||||
<include 'scripts/IosSetupSteps.txt'>
|
||||
|
||||
clean 'BuildSample/BuildSample.sln' for '{@sln_config}'
|
||||
build 'BuildSample/BuildSample.sln' for '{@sln_config}'
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
import unittest
|
||||
from utils.IncludeProcessor import IncludeProcessor
|
||||
|
||||
|
||||
class TestIncludeProcessor(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.processor = IncludeProcessor()
|
||||
|
||||
def test_getPathByIncludeStatement(self):
|
||||
statement = "< include 'Some Path'>"
|
||||
path = self.processor.getPathByIncludeStatement(statement)
|
||||
|
||||
self.assertEqual('Some Path', path)
|
||||
|
||||
def test_getInfos(self):
|
||||
text = """
|
||||
< include 'path1'>
|
||||
bla bla
|
||||
<include 'path2'>
|
||||
some text
|
||||
"""
|
||||
includeInfo = self.processor.getIncludesInfo(text)
|
||||
|
||||
self.assertEqual(2, len(includeInfo))
|
||||
|
||||
info0 = includeInfo[0]
|
||||
self.assertEqual("< include 'path1'>", info0[0])
|
||||
self.assertEqual('path1', info0[1])
|
||||
|
||||
info1 = includeInfo[1]
|
||||
self.assertEqual("<include 'path2'>", info1[0])
|
||||
self.assertEqual('path2', info1[1])
|
||||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import unittest
|
||||
from Core.LineConveyor.TextInclude import TextInclude
|
||||
from utils.IncludeProcessor import IncludeProcessor
|
||||
|
||||
|
||||
class MockContentProvider:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def fetchContent(self, path):
|
||||
return """line 1
|
||||
line 2
|
||||
line 3"""
|
||||
|
||||
class TestIncludeText(unittest.TestCase):
|
||||
def setUp(self):
|
||||
includeProcessor = IncludeProcessor()
|
||||
contentProvider = MockContentProvider()
|
||||
self.includeText = TextInclude(includeProcessor, contentProvider)
|
||||
|
||||
def test_includeText(self):
|
||||
text = """
|
||||
bla bla
|
||||
<include 'path1'>
|
||||
another bla
|
||||
<include 'paht2'>
|
||||
yet another bla"""
|
||||
|
||||
processedText = self.includeText.processText(text)
|
||||
|
||||
expected = """
|
||||
bla bla
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
another bla
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
yet another bla"""
|
||||
|
||||
self.assertEqual(expected, processedText)
|
||||
|
|
@ -8,12 +8,12 @@ class TestCommentRemover(unittest.TestCase):
|
|||
|
||||
def test_startsWithComment(self):
|
||||
line = '# this line is comment'
|
||||
newLine = self.commentRemover.processLine(line)
|
||||
newLine = self.commentRemover.processText(line)
|
||||
|
||||
self.assertEqual('', newLine)
|
||||
|
||||
def test_containsComment(self):
|
||||
line = 'this line contains # a comment'
|
||||
newLine = self.commentRemover.processLine(line)
|
||||
newLine = self.commentRemover.processText(line)
|
||||
|
||||
self.assertEqual('this line contains ', newLine)
|
||||
|
|
@ -21,6 +21,6 @@ class TestMacroResolver(unittest.TestCase):
|
|||
|
||||
def test_resolveLine(self):
|
||||
line = '{@key1} bla {@some_name} version: {@version}'
|
||||
newLine = self.macroResolver.processLine(line)
|
||||
newLine = self.macroResolver.processText(line)
|
||||
|
||||
self.assertEqual('hello world bla another name version: 1.2.3', newLine)
|
||||
|
|
@ -8,6 +8,6 @@ class TestStripper(unittest.TestCase):
|
|||
|
||||
def test_stripLine(self):
|
||||
line = ' \tSome text \t\r\n'
|
||||
newLine = self.stripper.processLine(line)
|
||||
newLine = self.stripper.processText(line)
|
||||
|
||||
self.assertEqual('Some text', newLine)
|
||||
|
|
@ -15,9 +15,7 @@ ios.tf_team_token = 'c5c3cf7a6dae2bea4382dfbd181a2075_Mjc4ODkwMjAxMy0wOS0yOSAxND
|
|||
ios.appstore.app_name = 'CoolApp'
|
||||
ios.appstore.sln_config = 'Release|iPhone'
|
||||
ios.appstore.author = 'Rustam'
|
||||
ios.appstore.version = '7.7.7'
|
||||
|
||||
ios.staging.app_name = 'CoolApp staging'
|
||||
ios.staging.steps = 'scripts/StagingSteps.txt'
|
||||
ios.staging.author = 'Fedor'
|
||||
ios.staging.version = '7.8.9'
|
||||
ios.staging.author = 'Fedor'
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import argparse
|
||||
from Core.FileContentProvider import FileContentProvider
|
||||
from Core.LineConveyor.CommentRemover import CommentRemover
|
||||
from Core.LineConveyor.LineConveyor import LineConveyor
|
||||
from Core.LineConveyor.TextConveyorPreprocessor import TextConveyorPreprocessor
|
||||
from Core.LineConveyor.MacroResolver import MacroResolver
|
||||
from Core.LineConveyor.Stripper import Stripper
|
||||
from Core.LineConveyor.TextInclude import TextInclude
|
||||
from commands.ValueProvider import ValueProvider
|
||||
from utils.BuildConfigProvider import BuildConfigProvider
|
||||
from utils.IncludeProcessor import IncludeProcessor
|
||||
from utils.MacroProcessor import MacroProcessor
|
||||
from utils.SettingsProvider.CmdArgsOverriderSettingsProvider import CmdArgsOverriderSettingsProvider
|
||||
from utils.SettingsProvider.FromFileSettingsProvider import FromFileSettingsProvider
|
||||
|
|
@ -35,10 +38,17 @@ class TaskRunner:
|
|||
self.valueProvider = ValueProvider()
|
||||
macroResolver = MacroResolver(macroProcessor, self.valueProvider)
|
||||
|
||||
self.lineConveyor = LineConveyor()
|
||||
self.lineConveyor.addProcessor(lineStripper)
|
||||
self.lineConveyor.addProcessor(commentRemover)
|
||||
self.lineConveyor.addProcessor(macroResolver)
|
||||
includeProcessor = IncludeProcessor()
|
||||
self.fileContentProvider = FileContentProvider()
|
||||
textInclude = TextInclude(includeProcessor, self.fileContentProvider)
|
||||
|
||||
self.textPreprocessor = TextConveyorPreprocessor()
|
||||
self.textPreprocessor.addProcessor(textInclude)
|
||||
self.textPreprocessor.addProcessor(macroResolver)
|
||||
|
||||
self.linePreprocessor = TextConveyorPreprocessor()
|
||||
self.linePreprocessor.addProcessor(lineStripper)
|
||||
self.linePreprocessor.addProcessor(commentRemover)
|
||||
|
||||
def run(self):
|
||||
rawSettings = self.settingsProvider.fetchSettings()
|
||||
|
|
@ -51,14 +61,15 @@ class TaskRunner:
|
|||
def runConfig(self, config):
|
||||
content = self.getStepsContent(config)
|
||||
|
||||
stepsRunner = StepsRunner(config, self.lineConveyor, self.valueProvider)
|
||||
stepsRunner = StepsRunner(config, self.linePreprocessor, self.valueProvider)
|
||||
stepsRunner.run(content)
|
||||
|
||||
def getStepsContent(self, config):
|
||||
pathToSteps = config['steps']
|
||||
stepsFile = open(pathToSteps)
|
||||
|
||||
content = stepsFile.read()
|
||||
content = self.fileContentProvider.fetchContent(pathToSteps)
|
||||
content = self.textPreprocessor.processText(content)
|
||||
|
||||
return content
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
import re
|
||||
from parser.LineParser import LineParser
|
||||
|
||||
|
||||
class IncludeProcessor(LineParser):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def getIncludesInfo(self, text):
|
||||
assert text is not None
|
||||
|
||||
regexpSource = '<\s*' + self.than('include') + r"'[^']+'" + '\s*>'
|
||||
|
||||
regexp = re.compile(regexpSource, re.UNICODE)
|
||||
results = regexp.findall(text)
|
||||
|
||||
includesInfo = []
|
||||
if results:
|
||||
for r in results:
|
||||
path = self.getPathByIncludeStatement(r)
|
||||
includesInfo.append((r, path))
|
||||
|
||||
return includesInfo
|
||||
|
||||
def getPathByIncludeStatement(self, includeStatement):
|
||||
assert includeStatement is not None
|
||||
|
||||
regexpSource = r"'([^']+)'"
|
||||
regexp = re.compile(regexpSource, re.UNICODE)
|
||||
|
||||
results = regexp.findall(includeStatement)
|
||||
path = results[0]
|
||||
|
||||
return path
|
||||
Loading…
Reference in New Issue