• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19250292619

11 Nov 2025 12:09AM UTC coverage: 77.865% (-2.4%) from 80.298%
19250292619

push

github

web-flow
flag non-runnable targets used with `code_quality_tool` (#22875)

2 of 5 new or added lines in 2 files covered. (40.0%)

1487 existing lines in 72 files now uncovered.

71448 of 91759 relevant lines covered (77.86%)

3.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

24.0
/src/python/pants/init/util.py
1
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
import os
11✔
5
from typing import cast
11✔
6

7
from pants.fs.fs import safe_filename_from_path
11✔
8
from pants.option.option_value_container import OptionValueContainer
11✔
9
from pants.util.dirutil import absolute_symlink, safe_mkdir, safe_rmtree
11✔
10

11

12
def init_workdir(global_options: OptionValueContainer) -> str:
11✔
13
    """Given the bootstrap options (generally immediately after bootstrap), initialize the workdir.
14

15
    If it is in use, the "physical" workdir is a directory under the `pants_physical_workdir_base`
16
    that is unique to each working copy (via including the entire path to the working copy in its
17
    name using `safe_filename_from_path`).
18
    """
UNCOV
19
    workdir_src = cast(str, global_options.pants_workdir)
×
UNCOV
20
    if not global_options.pants_physical_workdir_base:
×
21
        safe_mkdir(workdir_src)
×
22
        return workdir_src
×
23

UNCOV
24
    workdir_base = global_options.pants_physical_workdir_base
×
UNCOV
25
    workdir_dst = os.path.join(workdir_base, safe_filename_from_path(workdir_src))
×
26

UNCOV
27
    def create_symlink_to_clean_workdir():
×
28
        # Executed when no link exists. We treat this as equivalent to a request to have deleted
29
        # this state. Operations like `clean-all` will already have purged the destination, but in
30
        # cases like manual removal of the symlink, we want to treat the case as equivalent.
UNCOV
31
        safe_mkdir(workdir_dst, clean=True)
×
UNCOV
32
        absolute_symlink(workdir_dst, workdir_src)
×
33

UNCOV
34
    if not os.path.lexists(workdir_src):
×
35
        # Does not exist.
36
        create_symlink_to_clean_workdir()
×
UNCOV
37
    elif os.path.islink(workdir_src):
×
38
        if os.readlink(workdir_src) != workdir_dst:
×
39
            # Exists but is incorrect.
40
            os.unlink(workdir_src)
×
41
            create_symlink_to_clean_workdir()
×
42
        else:
43
            # Exists and is correct: ensure that the destination exists.
44
            safe_mkdir(workdir_dst)
×
45
    else:
46
        # Remove existing physical workdir (.pants.d/workdir dir)
UNCOV
47
        safe_rmtree(workdir_src)
×
48
        # Create both symlink workdir (.pants.d/workdir dir) and its destination/physical workdir
UNCOV
49
        create_symlink_to_clean_workdir()
×
UNCOV
50
    return workdir_src
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc