本文整理汇总了Python中shared.run_peru_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_peru_command函数的具体用法?Python run_peru_command怎么用?Python run_peru_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_peru_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_relative_override_from_subdir
def test_relative_override_from_subdir(self):
self.write_peru_yaml('''\
empty module foo:
imports:
foo: ./
''')
# Create some subdirs inside the project.
subdir = os.path.join(self.test_dir, 'a', 'b')
peru.compat.makedirs(subdir)
# Create an override dir outside the project.
override_dir = shared.create_dir({'foo': 'override'})
# Set the override from inside subdir, using the relative path that's
# valid from that location. Peru is going to store this path in
# .peru/overrides/ at the root, so this tests that we resolve the
# stored path properly.
relative_path = os.path.relpath(override_dir, start=subdir)
run_peru_command(['override', 'add', 'foo', relative_path],
subdir)
# Confirm that the right path is stored on disk.
expected_stored_path = os.path.relpath(
override_dir, start=self.test_dir)
with open(os.path.join(self.peru_dir, "overrides", "foo")) as f:
actual_stored_path = f.read()
self.assertEqual(expected_stored_path, actual_stored_path)
# Confirm that `peru override` prints output that respects the cwd.
output = run_peru_command(['override'], subdir)
self.assertEqual("foo: {}\n".format(relative_path), output)
# Confirm that syncing works.
self.do_integration_test(['sync'], {'foo': 'override'}, cwd=subdir)
开发者ID:Arvindhm,项目名称:peru,代码行数:30,代码来源:test_sync.py
示例2: test_flags_override_vars
def test_flags_override_vars(self):
flag_cache_dir = shared.create_dir()
env_cache_dir = shared.create_dir()
shared.run_peru_command(['--cache-dir', flag_cache_dir, 'sync'],
self.cwd,
env={'PERU_CACHE_DIR': env_cache_dir})
self.assert_success(self.project_dir, self.state_dir, flag_cache_dir)
开发者ID:emgee,项目名称:peru,代码行数:7,代码来源:test_paths.py
示例3: test_recursive_import_error
def test_recursive_import_error(self):
'''Errors that happen inside recursively-fetched targets should have
context information about the targets that caused them. This test is
especially important for checking that context isn't lost in
GatheredExceptions.'''
# Project NOTABLE_NAME has a BAD_MODULE in it.
dir_notable = shared.create_dir()
# Create the peru.yaml file for NOTABLE_NAME.
self.write_yaml('''\
imports:
BAD_MODULE: ./
git module BAD_MODULE:
bad_field: stuff
# The error we get here will actually be that `url` is missing.
''', dir=dir_notable)
# Now make our test project import it.
self.write_yaml('''\
imports:
NOTABLE_NAME: ./notable
cp module NOTABLE_NAME:
recursive: true
path: {}
''', dir_notable)
with self.assertRaises(peru.error.PrintableError) as cm:
run_peru_command(['sync'], self.test_dir)
self.assertIn("NOTABLE_NAME", cm.exception.message)
self.assertIn("BAD_MODULE", cm.exception.message)
开发者ID:oconnor663,项目名称:peru,代码行数:28,代码来源:test_sync.py
示例4: do_integration_test
def do_integration_test(self, args, expected, *, cwd=None,
**peru_cmd_kwargs):
if not cwd:
cwd = self.test_dir
run_peru_command(args, cwd, **peru_cmd_kwargs)
assert_contents(self.test_dir, expected,
excludes=[DEFAULT_PERU_FILE_NAME, '.peru'])
开发者ID:eramosfigueroa,项目名称:peru-1,代码行数:7,代码来源:test_sync.py
示例5: test_rules_in_override
def test_rules_in_override(self):
def _write_peru_yaml(target):
self.write_peru_yaml('''\
imports:
TARGET: ./
cp module foo:
path: {}
rule test_build:
build: |
printf fee >> fi
mkdir -p subdir
printf fo >> subdir/fum
rule test_export:
export: subdir
'''.replace('TARGET', target))
_write_peru_yaml('foo|test_build')
override_dir = shared.create_dir()
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
# Syncing against a build rule should build in the override.
self.do_integration_test(['sync'], {'fi': 'fee', 'subdir/fum': 'fo'})
# Another sync should run the build again.
self.do_integration_test(
['sync'], {'fi': 'feefee', 'subdir/fum': 'fofo'})
# Make sure export dirs are respected in rules that come after.
_write_peru_yaml('foo|test_build|test_export|test_build')
self.do_integration_test(
['sync'], {'fum': 'fofofo', 'fi': 'fee', 'subdir/fum': 'fo'})
开发者ID:Arvindhm,项目名称:peru,代码行数:35,代码来源:test_sync.py
示例6: test_reup_all
def test_reup_all(self):
yaml_with_imports = dedent('''\
imports:
foo: ./
bar: ./
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
''').format(self.foo_dir, self.foo_master, self.bar_dir)
test_dir = shared.create_dir({'peru.yaml': yaml_with_imports})
expected = dedent('''\
imports:
foo: ./
bar: ./
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
rev: {}
''').format(self.foo_dir, self.foo_master, self.bar_dir,
self.bar_otherbranch)
run_peru_command(['reup'], test_dir)
# This time we finally pull in barfile.
assert_contents(test_dir,
{'peru.yaml': expected, 'a': 'b', 'barfile': 'new'},
excludes=['.peru'])
开发者ID:emgee,项目名称:peru,代码行数:35,代码来源:test_reup.py
示例7: test_identical_plugin_cache_fields
def test_identical_plugin_cache_fields(self):
# Plugins that use caching also need to avoid running in parallel, if
# their cache directories are the same. The noop_cache plugin (created
# for this test) uses the path field (but not the nonce field) in its
# plugin cache key. Check that these two modules are not fetched in
# parallel, even though their module fields aren't exactly the same.
foo = shared.create_dir()
peru_yaml = dedent('''\
imports:
foo1: ./
foo2: ./
noop_cache module foo1:
path: {}
# nonce is ignored, but it makes foo1 different from foo2 as
# far as the module cache is concerned
nonce: '1'
noop_cache module foo2:
path: {}
nonce: '2'
'''.format(foo, foo))
test_dir = shared.create_dir({'peru.yaml': peru_yaml})
shared.run_peru_command(['sync'], test_dir)
assert_parallel(1)
开发者ID:Arvindhm,项目名称:peru,代码行数:25,代码来源:test_parallelism.py
示例8: test_relative_paths
def test_relative_paths(self):
'''We ran into a bug where calling os.path.dirname(peru_file) was
returning "", which got passed as the cwd of a plugin job and blew up.
This test repros that case. We've switched to pathlib.Path.parent to
fix the issue.'''
shared.run_peru_command(
['--file', 'peru.yaml', '--sync-dir', '.', 'sync'],
cwd=self.project_dir)
self.assert_success(self.project_dir, self.state_dir, self.cache_dir)
开发者ID:emgee,项目名称:peru,代码行数:9,代码来源:test_paths.py
示例9: test_override_after_regular_sync
def test_override_after_regular_sync(self):
self.write_peru_yaml(self.override_test_yaml)
# First, do a regular sync.
self.do_integration_test(['sync'], {'builtfoo': 'bar!'})
# Now, add an override, and confirm that the new sync works.
override_dir = shared.create_dir({'foo': 'override'})
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
self.do_integration_test(['sync'], {'builtfoo': 'override!'})
开发者ID:Arvindhm,项目名称:peru,代码行数:9,代码来源:test_sync.py
示例10: test_setting_all_flags
def test_setting_all_flags(self):
cwd = shared.create_dir()
sync_dir = shared.create_dir()
state_dir = shared.create_dir()
cache_dir = shared.create_dir()
shared.run_peru_command(
['--file', self.peru_file, '--sync-dir', sync_dir,
'--state-dir', state_dir, '--cache-dir', cache_dir, 'sync'],
cwd)
self.assert_success(sync_dir, state_dir, cache_dir)
开发者ID:emgee,项目名称:peru,代码行数:10,代码来源:test_paths.py
示例11: test_override_excludes_dotperu
def test_override_excludes_dotperu(self):
self.write_peru_yaml('''\
empty module foo:
imports:
foo: ./
''')
override_dir = shared.create_dir(
{'foo': 'override', '.peru/bar': 'baz'})
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
self.do_integration_test(['sync'], {'foo': 'override'})
开发者ID:Arvindhm,项目名称:peru,代码行数:12,代码来源:test_sync.py
示例12: test_number_of_git_commands
def test_number_of_git_commands(self):
'''A no-op sync should be a single git command. Also check that index
files are deleted after any sync error.'''
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml(
'''\
cp module foo:
path: {}
imports:
foo: subdir
''', module_dir)
index_path = os.path.join(self.test_dir, '.peru/lastimports.index')
# The first sync should take multiple operations and create a
# lastimports.index file.
peru.cache.DEBUG_GIT_COMMAND_COUNT = 0
self.do_integration_test(['sync'], {'subdir/foo': 'bar'})
assert peru.cache.DEBUG_GIT_COMMAND_COUNT > 1, \
'The first sync should take multiple operations.'
assert os.path.exists(index_path), \
'The first sync should create an index file.'
# The second sync should reuse the index file and only take one
# operation.
peru.cache.DEBUG_GIT_COMMAND_COUNT = 0
self.do_integration_test(['sync'], {'subdir/foo': 'bar'})
assert peru.cache.DEBUG_GIT_COMMAND_COUNT == 1, \
'The second sync should take only one operation.'
assert os.path.exists(index_path), \
'The second sync should preserve the index file.'
# Now force an error. This should delete the index file.
with open(os.path.join(self.test_dir, 'subdir/foo'), 'w') as f:
f.write('dirty')
with self.assertRaises(peru.cache.DirtyWorkingCopyError):
run_peru_command(['sync'], self.test_dir)
assert not os.path.exists(index_path), \
'The error should delete the index file.'
# Fix the error and resync with new module contents. This should
# recreate the index file with the current tree and then succeed,
# rather than using an empty index and treating the current files as
# conflicting.
with open(os.path.join(self.test_dir, 'subdir/foo'), 'w') as f:
f.write('bar')
with open(os.path.join(module_dir, 'foo'), 'w') as f:
f.write('new bar')
self.do_integration_test(['sync', '--no-cache'],
{'subdir/foo': 'new bar'})
assert os.path.exists(index_path), \
'The index should have been recreated.'
开发者ID:buildinspace,项目名称:peru,代码行数:52,代码来源:test_sync.py
示例13: test_single_reup
def test_single_reup(self):
expected = dedent('''\
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
''').format(self.foo_dir, self.foo_master, self.bar_dir)
run_peru_command(['reup', 'foo'], self.test_dir)
assert_contents(self.test_dir, {'peru.yaml': expected},
excludes=['.peru'])
开发者ID:mgartner,项目名称:peru,代码行数:13,代码来源:test_reup.py
示例14: test_override
def test_override(self):
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml(
'''\
cp module foo:
path: {}
imports:
foo: ./
''', module_dir)
override_dir = shared.create_dir({'foo': 'override'})
# Set the override.
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
# Confirm that the override is configured.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Make sure 'override list' gives the same output as 'override'.
output = run_peru_command(['override', 'list'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Same as above, but as JSON (with --json flag).
output = run_peru_command(['override', '--json'], self.test_dir)
override_dict = json.loads(output)
self.assertEqual(override_dict, {'foo': override_dir})
# Run the sync with --no-overrides and confirm nothing changes. Also
# check that there's no overrides-related output.
output = self.do_integration_test(['sync', '--no-overrides'],
{'foo': 'bar'})
self.assertNotIn('overrides', output)
# Now run the sync normally and confirm that the override worked. Also
# confirm that we mentioned the override in output, and that the unused
# overrides warning is not printed.
output = self.do_integration_test(['sync'], {'foo': 'override'})
self.assertIn('overrides', output)
self.assertNotIn('WARNING unused overrides', output)
# Delete the override.
run_peru_command(['override', 'delete', 'foo'], self.test_dir)
# Confirm that the override was deleted.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, '')
# Rerun the sync and confirm the original content is back.
self.do_integration_test(['sync'], {'foo': 'bar'})
# Add a bogus override and confirm the unused overrides warning is
# printed.
run_peru_command(['override', 'add', 'bogus', override_dir],
self.test_dir)
output = self.do_integration_test(['sync'], {'foo': 'bar'})
self.assertIn('WARNING unused overrides', output)
开发者ID:buildinspace,项目名称:peru,代码行数:48,代码来源:test_sync.py
示例15: test_module_list
def test_module_list(self):
self.write_yaml('''\
git module foo:
url: blah
git module bar:
url: blah
''')
output = run_peru_command(['module'], self.test_dir)
self.assertEqual(output, "bar\nfoo\n")
output = run_peru_command(['module', 'list'], self.test_dir)
self.assertEqual(output, "bar\nfoo\n")
output = run_peru_command(['module', 'list', '--json'], self.test_dir)
self.assertEqual(output, '["bar", "foo"]\n')
开发者ID:oconnor663,项目名称:peru,代码行数:16,代码来源:test_sync.py
示例16: test_override_after_regular_sync
def test_override_after_regular_sync(self):
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml('''\
cp module foo:
path: {}
imports:
foo: ./
''', module_dir)
# First, do a regular sync.
self.do_integration_test(['sync'], {'foo': 'bar'})
# Now, add an override, and confirm that the new sync works.
override_dir = shared.create_dir({'foo': 'override'})
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
self.do_integration_test(['sync'], {'foo': 'override'})
开发者ID:oconnor663,项目名称:peru,代码行数:16,代码来源:test_sync.py
示例17: test_build_output
def test_build_output(self):
# Make sure build commands are sending their output to the display like
# they're supposed do. This also has the effect of testing that modules
# and rules are cached like they're supposed to be -- if not, they'll
# show up in the output more than once.
self.write_peru_yaml('''\
imports:
basic: dir1/
basic|complicated: dir2/
cp module basic:
path: {}
build: echo foo
rule complicated:
build: echo bar
''')
expected_output = dedent('''\
=== started basic ===
=== finished basic ===
foo
bar
''')
output = run_peru_command(['sync', '-v'], self.test_dir)
self.assertEqual(expected_output, output)
开发者ID:Arvindhm,项目名称:peru,代码行数:25,代码来源:test_sync.py
示例18: test_override_recursive
def test_override_recursive(self):
# Module A just includes the file 'foo'.
module_a_dir = shared.create_dir({'foo': 'bar'})
# Module B imports module A.
module_b_dir = shared.create_dir()
self.write_yaml(
'''\
cp module A:
path: {}
imports:
A: A/
''',
module_a_dir,
dir=module_b_dir)
# Module C (in self.test_dir) imports module B, and also directly
# imports module A. When we set an override for module A below, we'll
# want to check that *both* of these imports get overridden.
self.write_yaml(
'''\
cp module B:
path: {}
recursive: true
# Note that module business happens before rule business, so
# 'drop: peru.yaml' will not affect the recursion, just the
# final output.
drop: peru.yaml
imports:
B.A: A/
B: B/
''', module_b_dir)
# First, do a regular sync.
self.do_integration_test(['sync'], {
'A/foo': 'bar',
'B/A/foo': 'bar',
})
# Now set an override for B.A.
override_dir = shared.create_dir({'foo': 'override'})
run_peru_command(['override', 'add', 'B.A', override_dir],
self.test_dir)
# Now do another sync. *Both* the directly imported copy of A *and* the
# copy synced inside of B should be overridden.
self.do_integration_test(['sync'], {
'A/foo': 'override',
'B/A/foo': 'override',
})
开发者ID:buildinspace,项目名称:peru,代码行数:47,代码来源:test_sync.py
示例19: test_duplicate_keys_warning
def test_duplicate_keys_warning(self):
self.write_yaml('''\
git module foo:
git module foo:
''')
buffer = io.StringIO()
with redirect_stderr(buffer):
run_peru_command(['sync'], self.test_dir)
assert('WARNING' in buffer.getvalue())
assert('git module foo' in buffer.getvalue())
# Make sure --quiet suppresses the warning.
buffer = io.StringIO()
with redirect_stderr(buffer):
run_peru_command(['sync', '--quiet'], self.test_dir)
# Don't literally check that stderr is empty, because that could get
# tripped up on other Python warnings (like asyncio taking too long).
assert 'git module foo' not in buffer.getvalue()
开发者ID:oconnor663,项目名称:peru,代码行数:17,代码来源:test_sync.py
示例20: test_rules_in_override
def test_rules_in_override(self):
module_dir = shared.create_dir({'a/b': 'c'})
yaml = '''
imports:
foo|get_a: ./
cp module foo:
path: {}
rule get_a:
export: a
'''
self.write_yaml(yaml, module_dir)
override_dir = shared.create_dir({'a/b': 'override'})
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
self.do_integration_test(['sync'], {'b': 'override'})
开发者ID:oconnor663,项目名称:peru,代码行数:17,代码来源:test_sync.py
注:本文中的shared.run_peru_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论