runtests.jl (2493B)
1 # -------------------------------------------------------------------------------------------------- 2 # using Revise; import Pkg; Pkg.activate(".") # for debugging 3 4 using FinanceRoutines 5 using Test 6 7 import DataFrames: DataFrame, allowmissing!, AsTable, ByRow, combine, groupby, innerjoin, 8 insertcols!, leftjoin, nrow, names, rename!, select, subset, transform! 9 import DataPipes: @p 10 # -------------------------------------------------------------------------------------------------- 11 12 13 # -------------------------------------------------------------------------------------------------- 14 const testsuite = [ 15 "KenFrench", 16 "FF5", 17 "WRDS", 18 "betas", 19 "Yields", 20 "PortfolioUtils", 21 "Diagnostics", 22 "EventStudy", 23 ] 24 # -------------------------------------------------------------------------------------------------- 25 26 27 # -------------------------------------------------------------------------------------------------- 28 # To run file locally (where environment variables are not defined by CI) 29 env_file = "/Users/loulou/Documents/data/.env/.env.gpg" 30 if isfile(env_file) 31 io = IOBuffer(); run(pipeline(`which gpg`; stdout=io)); gpg_cmd = strip(String(take!(io))) 32 io = IOBuffer(); 33 cmd = run(pipeline(`$gpg_cmd --decrypt $env_file`; stdout=io, stderr=devnull)); 34 env_WRDS = String(take!(io)) 35 # populate the environment variables 36 for line in split(env_WRDS, "\n") 37 startswith(line, "#") && continue 38 isempty(strip(line)) && continue 39 if contains(line, "=") 40 key, value = split(line, "=", limit=2) 41 ENV[strip(key)] = strip(value) 42 end 43 end 44 end 45 # -------------------------------------------------------------------------------------------------- 46 47 48 # -------------------------------------------------------------------------------------------------- 49 @testset verbose=true "FinanceRoutines.jl" begin 50 # Write your tests here. 51 52 # just for checking things on the fly 53 @testset "Debugging tests ..." begin 54 WRDS_USERNAME = get(ENV, "WRDS_USERNAME", "") 55 WRDS_PWD = get(ENV, "WRDS_PWD", "") 56 @test !isempty(WRDS_USERNAME) 57 @test !isempty(WRDS_PWD) 58 end 59 60 # Actual tests 61 for test in testsuite 62 println("\033[1m\033[32m → RUNNING\033[0m: $(test)") 63 include("UnitTests/$(test).jl") 64 println("\033[1m\033[32m PASSED\033[0m") 65 end 66 67 end 68 # --------------------------------------------------------------------------------------------------