Skip to content

Commit

Permalink
Enable fromfile support for --owner-of and increase test coverage (#5948
Browse files Browse the repository at this point in the history
)

### Problem

The new `--owner-of` option was broken in the context of `pantsd`, but didn't have test coverage due to the `--changed` and `--owner-of` tests not running under `pantsd`. Additionally, `fromfile` support is useful for this option, but was not enabled. 

### Solution

Mark some integration tests as needing to run under the daemon, and enable `fromfile` support for `--owner-of`.
  • Loading branch information
Stu Hood committed Jun 12, 2018
1 parent 4e531ae commit 6086189
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/docs/target_addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ The following target addresses all specify the same single target.
$ ./pants --owner-of=examples/src/java/org/pantsbuild/example/hello/main/HelloMain.java list
examples/src/java/org/pantsbuild/example/hello/main:main

It's also worth noting that multiple passes of `owner-of=` are accepted in order to work with multiple
files and pants will execute the goal on all the targets that own those files.
It's also worth noting that multiple instances of `--owner-of=` are accepted in order to work with multiple
files and pants will execute the goal on all the targets that own those files. Additionally, `fromfile`
support is enabled for this option, so passing `--owner-of=@file` (where "file" is a filename
containing a list of filenames to look up owners for) is supported.

- Relative paths and trailing forward slashes are ignored on the
command-line to accommodate tab completion:
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def register_bootstrap_options(cls, register):
register('--subproject-roots', type=list, advanced=True, fromfile=True, default=[],
help='Paths that correspond with build roots for any subproject that this '
'project depends on.')
register('--owner-of', type=list, default=[], metavar='<path>',
register('--owner-of', type=list, default=[], fromfile=True, metavar='<path>',
help='Select the targets that own these files. '
'This is the third target calculation strategy along with the --changed '
'options and specifying the targets directly. These three types of target '
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/pantsd/service/scheduler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def warm_product_graph(self, options, target_roots_calculator):
with self.fork_lock:
target_roots = target_roots_calculator.create(
options,
session,
session.scheduler_session,
session.symbol_table,
)
session.warm_product_graph(target_roots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pants.util.contextutil import environment_as, temporary_dir
from pants.util.dirutil import safe_delete, safe_mkdir, safe_open, touch
from pants_test.base_test import TestGenerator
from pants_test.pants_run_integration_test import PantsRunIntegrationTest
from pants_test.pants_run_integration_test import PantsRunIntegrationTest, ensure_daemon
from pants_test.testutils.git_util import initialize_repo


Expand Down Expand Up @@ -352,6 +352,7 @@ def test_changed_in_directory_without_build_file(self):
self.assert_success(pants_run)
self.assertEqual(pants_run.stdout_data.strip(), '')

@ensure_daemon
def test_list_changed(self):
deleted_file = 'src/python/sources/sources.py'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from pants_test.pants_run_integration_test import PantsRunIntegrationTest
from pants_test.pants_run_integration_test import PantsRunIntegrationTest, ensure_daemon


class ListOwnersIntegrationTest(PantsRunIntegrationTest):
@ensure_daemon
def test_owner_of_success(self):
pants_run = self.do_command('--owner-of=testprojects/tests/python/pants/dummies/test_pass.py',
'list',
Expand Down Expand Up @@ -44,4 +45,4 @@ def test_owner_list_two_target_specs(self):
'list',
'testprojects/tests/python/pants/dummies:passing_target',
success=False)
self.assertIn(expected_error, pants_run_3.stderr_data)
self.assertIn(expected_error, pants_run_3.stderr_data)

0 comments on commit 6086189

Please sign in to comment.