|
| 1 | +function check_hsg() |
| 2 | + assert_clean_working_directory() |
| 3 | + run_hsg() |
| 4 | + assert_clean_working_directory() |
| 5 | + return nothing |
| 6 | +end |
| 7 | + |
| 8 | +function assert_clean_working_directory() |
| 9 | + if !isempty(strip(read(`git status --short`, String))) |
| 10 | + msg = "The working directory is dirty" |
| 11 | + @error msg |
| 12 | + |
| 13 | + println("Output of `git status`:") |
| 14 | + println(strip(read(`git status`, String))) |
| 15 | + |
| 16 | + run(`git add -A`) |
| 17 | + |
| 18 | + println("Output of `git diff HEAD`:") |
| 19 | + println(strip(read(`git diff HEAD`, String))) |
| 20 | + |
| 21 | + run(`git reset`) |
| 22 | + |
| 23 | + throw(ErrorException(msg)) |
| 24 | + else |
| 25 | + @info "The working directory is clean" |
| 26 | + return nothing |
| 27 | + end |
| 28 | +end |
| 29 | + |
| 30 | +function run_hsg() |
| 31 | + env2 = copy(ENV) |
| 32 | + delete!(env2, "JULIA_DEPOT_PATH") |
| 33 | + delete!(env2, "JULIA_LOAD_PATH") |
| 34 | + delete!(env2, "JULIA_PROJECT") |
| 35 | + env2["JULIA_DEPOT_PATH"] = mktempdir(; cleanup = true) |
| 36 | + julia_binary = Base.julia_cmd().exec[1] |
| 37 | + hsg_directory = joinpath("ext", "HistoricaStdlibGenerator") |
| 38 | + hsg_generate_file = joinpath(hsg_directory, "generate_historical_stdlibs.jl") |
| 39 | + |
| 40 | + cmd_1 = `$(julia_binary) --project=$(hsg_directory) -e 'import Pkg; Pkg.instantiate()'` |
| 41 | + cmd_2 = `$(julia_binary) --project=$(hsg_directory) $(hsg_generate_file)` |
| 42 | + |
| 43 | + run(setenv(cmd_1, env2)) |
| 44 | + run(setenv(cmd_2, env2)) |
| 45 | + |
| 46 | + return nothing |
| 47 | +end |
| 48 | + |
| 49 | +check_hsg() |
0 commit comments