Пример #1
0
        def run_beaker_action(repo_name, branch):
            map_lines(
                "acceptance/Gemfile", r"gem ['\"]beaker['\"]",
                const("gem 'beaker', *location_for('file:///%s')\n" %
                      BeakerRunner.beaker_repo.root), 1)(repo_name, branch)

            with in_directory("acceptance"):
                if not os.path.exists("beaker-results"):
                    os.makedirs("beaker-results")
                if not os.path.exists(".bundle"):
                    bundle("install")

                hosts_cfg_path, abs_hosts, host = self.generate_abs_hosts(
                    host_layout)
                env_vars = self.env_vars(hosts_cfg_path)
                env_vars.update({
                    "ABS_RESOURCE_HOSTS":
                    json.dumps(abs_hosts, separators=(",", ":"))
                })

                exit_code = bundle("exec rake %s" % self.beaker_rake_task,
                                   env=env_vars)
                if exit_code != 0:
                    raise Exception(
                        "beaker failed to run successfully with the host layout of %s"
                        % host_layout)
                TimingResults.add_host(
                    host,
                    "log/latest/tests-timing-trees.json",
                    output_file="%s/%s-%s.json" %
                    (BEAKER_RESULTS_DIR, host['name'], host['platform']))
Пример #2
0
def link_to_local_beaker(repo, branch):
    repo.reset_branch(branch)
    repo[branch](
        map_lines(
            "acceptance/Gemfile", r"gem ['\"]beaker['\"]",
            const("gem 'beaker', *location_for('file:///%s')\n" % beaker.root),
            1),
        commit(
            "Link beaker to local repo so that timing results can be printed"))
Пример #3
0
def setup_facter():
    facter = Facter(workspace=WORKSPACE,
                    puppet_agent=puppet_agent,
                    stub_prefix=BRANCH_PREFIX)
    facter.reset_branch("master")
    facter["master"](
        after_line(
            "lib/src/logging/logging.cc", r"log\(level::warning",
            const("%slog(level::warning, \"BLAH MESSAGE FOR TRANSLATION\")" %
                  (" " * 16))),
        commit("Setting up a test environment for POT file generation!"))
Пример #4
0
def setup_leatherman():
    leatherman = Leatherman(workspace=WORKSPACE,
                            puppet_agent=puppet_agent,
                            stub_prefix=BRANCH_PREFIX)
    leatherman.reset_branch("master")
    leatherman["master"](
        after_line(
            "curl/src/client.cc",
            r"throw http_exception\(_\(\"failed to create cURL handle.\"\)\)",
            const("%s_(\"BLAH MESSAGE FOR TRANSLATION\")" % (" " * 12))),
        commit("Setting up a test environment for POT file generation!"))
Пример #5
0
def setup_puppet():
    puppet = Puppet(workspace=WORKSPACE,
                    puppet_agent=puppet_agent,
                    stub_prefix=BRANCH_PREFIX)
    puppet.reset_branch("master")
    puppet["master"](
        after_line(
            "lib/puppet/resource.rb", r"_\('",
            const("%smsg2 = _('Some dummy message for POT generation!')" %
                  (" " * 4))),
        commit("Setting up a test environment for POT file generation!"))
Пример #6
0
def setup_libwhereami():
    libwhereami = Libwhereami(workspace=WORKSPACE,
                              puppet_agent=puppet_agent,
                              stub_prefix=BRANCH_PREFIX)
    libwhereami.reset_branch("master")
    libwhereami["master"](
        after_line(
            "lib/src/sources/lparstat_source.cc",
            r"lparstat executable not found",
            const("%sLOG_WARNING(\"BLAH MESSAGE FOR TRANSLATION\")" %
                  (" " * 12))),
        commit("Setting up a test environment for POT file generation!"))
Пример #7
0
def setup_cpp_pcp_client():
    cpp_pcp_client = CppPcpClient(workspace=WORKSPACE,
                                  puppet_agent=puppet_agent,
                                  stub_prefix=BRANCH_PREFIX)
    cpp_pcp_client.reset_branch("master")
    cpp_pcp_client["master"](
        after_line(
            "lib/src/connector/connection.cc",
            r"WebSocket in 'connecting' state",
            const("%sLOG_WARNING(\"BLAH MESSAGE FOR TRANSLATION\")" %
                  (" " * 12))),
        commit("Setting up a test environment for POT file generation!"))
Пример #8
0
def setup_pxp_agent():
    pxp_agent = PxpAgent(workspace=WORKSPACE,
                         puppet_agent=puppet_agent,
                         stub_prefix=BRANCH_PREFIX)
    pxp_agent.reset_branch("master")
    pxp_agent["master"](
        after_line(
            "lib/src/modules/task.cc",
            r"Downloading the task file from the master-uri",
            const("%sLOG_WARNING(\"BLAH MESSAGE FOR TRANSLATION\")" %
                  (" " * 14))),
        commit("Setting up a test environment for POT file generation!"))
Пример #9
0
from workflow.repos.git_repository import *
from workflow.constants import *
from workflow.utils import (commit, const)

from test_scripts.test_utils import WORKSPACE

facter = GitRepository("facter", ["3.6.x", "3.9.x", "master"],
                       workspace=WORKSPACE)
facter.reset_branches()

facter.to_branch(
    "3.6.x", new_file("my_test_file", "1234\nIS\nNOT GOOD\nFOO"),
    modify_line("my_test_file", r"(\d*)", r"NUMBER: \g<1>"),
    remove_file("CMakeLists.txt"), rewrite_file("MAINTAINERS", "NO MAN"),
    new_file("test_after", "Line One\nLine Two\nLine Three"),
    after_lines("test_after", "Line", const("Some junk right below!")),
    new_file("test_before", "Line One\nLine Two\nLine Three"),
    before_lines("test_before", "Line", const("Some junk right before!")),
    rename_file("Rakefile", "MY_RAKEFILE"),
    delete_line("LICENSE", r"facter - Tool for collecting system facts."),
    delete_line("LICENSE", r"Licensed under the Apache License"),
    commit("Testing out some CRUD stuff!"))

contents = facter.in_branch("3.6.x", read_file("CONTRIBUTING.md"))

print("CONTRIBUTING CONTENTS:")
print(contents)

facter.in_branch(
    "3.6.x",
    new_file("Prompted_Push", "Prompting the 'git push'!"),
Пример #10
0
def delete_lines(file_path, line_re, n=-1):
    return map_lines(file_path, line_re, const(""))