|
173 | 173 | # This set tests that we haven't accidentally added or removed any public-looking
|
174 | 174 | # functions (i.e. ones that are not prefixed by _ basically).
|
175 | 175 | @testset "Public API" begin
|
176 |
| - public_symbols = Set( |
177 |
| - filter(names(JuliaHub; all=true)) do s |
178 |
| - # Internal functions and types, prefixed by _ |
179 |
| - startswith(string(s), "_") && return false |
180 |
| - # Internal macros, prefixed by _ |
181 |
| - startswith(string(s), "@_") && return false |
182 |
| - # Strange generated functions |
183 |
| - startswith(string(s), "#") && return false |
184 |
| - # Some core functions that are not relevant for the package |
185 |
| - s in [:eval, :include] && return false |
186 |
| - return true |
187 |
| - end, |
188 |
| - ) |
| 176 | + public_symbols = Set(JuliaHub._find_public_names()) |
189 | 177 | expected_public_symbols = Set([
|
190 | 178 | Symbol("@script_str"),
|
191 | 179 | :AbstractJobConfig, :AbstractJuliaHubApp,
|
|
194 | 182 | :Dataset, :DatasetReference, :DatasetVersion,
|
195 | 183 | :DefaultApp, :FileHash, :InvalidAuthentication, :InvalidRequestError, :Job,
|
196 | 184 | :WorkloadConfig, :JobFile, :JobLogMessage, :JobReference, :JobStatus,
|
197 |
| - :JuliaHub, :JuliaHubConnectionError, :JuliaHubError, |
| 185 | + :JuliaHubConnectionError, :JuliaHubError, |
198 | 186 | :JuliaHubException,
|
199 | 187 | :Limit, :NodeSpec, :PackageApp, :PackageJob, :Unlimited,
|
200 | 188 | :PermissionError, :script, :Secret, :UserApp,
|
|
223 | 211 | extra_expected_symbols = $(sprint(show, MIME"text/plain"(), extra_expected_symbols))
|
224 | 212 | """
|
225 | 213 | @test isempty(extra_expected_symbols)
|
| 214 | + # Make sure that on Julia versions that support the `public` keyword, |
| 215 | + # we are also marking the right symbols as public. |
| 216 | + if Base.isdefined(Base, :ispublic) |
| 217 | + @testset "ispublic: $(name)" for name in public_symbols |
| 218 | + @test Base.ispublic(JuliaHub, name) |
| 219 | + end |
| 220 | + private_names = setdiff( |
| 221 | + names(JuliaHub; all=true), |
| 222 | + public_symbols, |
| 223 | + [:JuliaHub], |
| 224 | + ) |
| 225 | + @testset "!ispublic: $(name)" for name in private_names |
| 226 | + @test !Base.ispublic(JuliaHub, name) |
| 227 | + end |
| 228 | + end |
226 | 229 | end
|
227 | 230 |
|
228 | 231 | @testset "Utilities" begin
|
|
0 commit comments