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

JuliaLang / julia / #37808

15 Jun 2024 01:40AM UTC coverage: 87.071% (-0.4%) from 87.487%
#37808

push

local

web-flow
Fix lowering for `export` and similar (#54812)

Keep things as raw symbols - don't try to rename them. Fixes #54805.

76685 of 88072 relevant lines covered (87.07%)

15275639.11 hits per line

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

0.0
/stdlib/REPL/src/Pkg_beforeload.jl
1
## Pkg stuff needed before Pkg has loaded
2

3
const Pkg_pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
4
const Pkg_REPLExt_pkgid = Base.PkgId(Base.UUID("ceef7b17-42e7-5b1c-81d4-4cc4a2494ccf"), "REPLExt")
5

6
function load_pkg()
×
7
    @lock Base.require_lock begin
×
8
        REPLExt = Base.require_stdlib(Pkg_pkgid, "REPLExt")
×
9
        # require_stdlib does not guarantee that the `__init__` of the package is done when loading is done async
10
        # but we need to wait for the repl mode to be set up
11
        lock = get(Base.package_locks, Pkg_REPLExt_pkgid.uuid, nothing)
×
12
        lock !== nothing && wait(lock[2])
13
        return REPLExt
×
14
    end
15
end
16

17
## Below here copied/tweaked from Pkg Types.jl so that the dummy Pkg prompt
18
# can populate the env correctly before Pkg loads
19

20
function safe_realpath(path)
×
21
    isempty(path) && return path
×
22
    if ispath(path)
×
23
        try
×
24
            return realpath(path)
×
25
        catch
26
            return path
×
27
        end
28
    end
29
    a, b = splitdir(path)
×
30
    return joinpath(safe_realpath(a), b)
×
31
end
32

33
function find_project_file(env::Union{Nothing,String}=nothing)
×
34
    project_file = nothing
×
35
    if env isa Nothing
×
36
        project_file = Base.active_project()
×
37
        project_file === nothing && return nothing # in the Pkg version these are pkgerrors
×
38
    elseif startswith(env, '@')
×
39
        project_file = Base.load_path_expand(env)
×
40
        project_file === nothing && return nothing
×
41
    elseif env isa String
×
42
        if isdir(env)
×
43
            isempty(readdir(env)) || return nothing
×
44
            project_file = joinpath(env, Base.project_names[end])
×
45
        else
46
            project_file = endswith(env, ".toml") ? abspath(env) :
×
47
                abspath(env, Base.project_names[end])
48
        end
49
    end
50
    @assert project_file isa String &&
×
51
        (isfile(project_file) || !ispath(project_file) ||
52
         isdir(project_file) && isempty(readdir(project_file)))
53
    return safe_realpath(project_file)
×
54
end
55

56
function find_root_base_project(start_project::String)
×
57
    project_file = start_project
×
58
    while true
×
59
        base_project_file = Base.base_project(project_file)
×
60
        base_project_file === nothing && return project_file
×
61
        project_file = base_project_file
×
62
    end
×
63
end
64

65
function relative_project_path(project_file::String, path::String)
×
66
    # compute path relative the project
67
    # realpath needed to expand symlinks before taking the relative path
68
    return relpath(safe_realpath(abspath(path)), safe_realpath(dirname(project_file)))
×
69
end
70

71
function projname(project_file::String)
×
72
    if isfile(project_file)
×
73
        name = try
×
74
            p = Base.TOML.Parser()
×
75
            Base.TOML.reinit!(p, read(project_file, String); filepath=project_file)
×
76
            proj = Base.TOML.parse(p)
×
77
            get(proj, "name", nothing)
×
78
        catch
79
            nothing
×
80
        end
81
    else
82
        name = nothing
×
83
    end
84
    if name === nothing
×
85
        name = basename(dirname(project_file))
×
86
    end
87
    for depot in Base.DEPOT_PATH
×
88
        envdir = joinpath(depot, "environments")
×
89
        if startswith(abspath(project_file), abspath(envdir))
×
90
            return "@" * name
×
91
        end
92
    end
×
93
    return name
×
94
end
95

96
prev_project_file = nothing
97
prev_project_timestamp = nothing
98
prev_prefix = ""
99

100
function Pkg_promptf()
×
101
    global prev_project_timestamp, prev_prefix, prev_project_file
×
102
    project_file = find_project_file()
×
103
    prefix = ""
×
104
    if project_file !== nothing
×
105
        if prev_project_file == project_file && prev_project_timestamp == mtime(project_file)
×
106
            prefix = prev_prefix
×
107
        else
108
            project_name = projname(project_file)
×
109
            if project_name !== nothing
×
110
                root = find_root_base_project(project_file)
×
111
                rootname = projname(root)
×
112
                if root !== project_file
×
113
                    path_prefix = "/" * dirname(relative_project_path(root, project_file))
×
114
                else
115
                    path_prefix = ""
×
116
                end
117
                if textwidth(rootname) > 30
×
118
                    rootname = first(rootname, 27) * "..."
×
119
                end
120
                prefix = "($(rootname)$(path_prefix)) "
×
121
                prev_prefix = prefix
×
122
                prev_project_timestamp = mtime(project_file)
×
123
                prev_project_file = project_file
×
124
            end
125
        end
126
    end
127
    # Note no handling of Pkg.offline, as the Pkg version does here
128
    return "$(prefix)pkg> "
×
129
end
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

© 2026 Coveralls, Inc