@@ -21,15 +21,16 @@ function with_temp_depot(f::Function)
2121end
2222
2323# Taken from Prefernces.jl/test/runtests.jl
24- function activate_and_run (project_dir:: String , code:: String ; env:: Dict = Dict ())
24+ function activate_and_run (project_dir:: String , code:: String ; env:: Dict = Dict ())
2525 mktempdir () do dir
2626 open (joinpath (dir, " test_code.jl" ), " w" ) do io
2727 write (io, code)
2828 end
2929
3030 out = Pipe ()
31- cmd = setenv (` $(Base. julia_cmd ()) --project=$(project_dir) $(dir) /test_code.jl` ,
32- env... , " JULIA_DEPOT_PATH" => Base. DEPOT_PATH [1 ])
31+ cmd =
32+ setenv (` $(Base. julia_cmd ()) --project=$(project_dir) $(dir) /test_code.jl` ,
33+ env... , " JULIA_DEPOT_PATH" => Base. DEPOT_PATH [1 ])
3334 p = run (pipeline (cmd, stdout = out, stderr = out); wait= false )
3435 close (out. in)
3536 wait (p)
@@ -43,7 +44,7 @@ function activate_and_run(project_dir::String, code::String; env::Dict = Dict())
4344end
4445
4546@testset " Dial" begin
46- for n = 0 : 9
47+ for n in 0 : 9
4748 @test length (split (n2d (n). str, " \n " )) == 9
4849 @test length (split (n2d (n), " \n " )) == 9
4950 end
7374end
7475
7576@testset " setup_timer" begin
76- @test setup_timer (hour = 1 ) == Time (1 , 0 , 0 )
77- @test setup_timer (minute = 2 ) == Time (0 , 2 , 0 )
78- @test setup_timer (second = 3 ) == Time (0 , 0 , 3 )
79- @test setup_timer (hour = 1 , minute = 2 , second = 3 ) == Time (1 , 2 , 3 )
77+ @test setup_timer (hour= 1 ) == Time (1 , 0 , 0 )
78+ @test setup_timer (minute= 2 ) == Time (0 , 2 , 0 )
79+ @test setup_timer (second= 3 ) == Time (0 , 0 , 3 )
80+ @test setup_timer (hour= 1 , minute= 2 , second= 3 ) == Time (1 , 2 , 3 )
8081end
8182
8283@testset " preference" begin
83- local_prefs_toml = joinpath (dirname (dirname (pathof (TerminalClock))), " LocalPreferences.toml" )
84+ local_prefs_toml =
85+ joinpath (dirname (dirname (pathof (TerminalClock))), " LocalPreferences.toml" )
8486 rm (local_prefs_toml; force= true )
8587 with_temp_depot () do
86- project_dir = joinpath (dirname (@__DIR__ , ))
88+ project_dir = joinpath (dirname (@__DIR__ ))
8789
8890 # test for set_dials
89- activate_and_run (project_dir, """
90- using Pkg; Pkg.instantiate()
91- using TerminalClock
92- unicodebox = joinpath(dirname(pathof(TerminalClock)), "dials", "UnicodeBox.toml")
93- TerminalClock.set_dials(unicodebox)
94- """ )
91+ activate_and_run (
92+ project_dir,
93+ """
94+ using Pkg; Pkg.instantiate()
95+ using TerminalClock
96+ unicodebox = joinpath(dirname(pathof(TerminalClock)), "dials", "UnicodeBox.toml")
97+ TerminalClock.set_dials(unicodebox)
98+ """ ,
99+ )
95100 prefs = local_prefs_toml |> TOML. parsefile
96101 @test haskey (prefs, " TerminalClock" )
97102 @test basename (prefs[" TerminalClock" ][" tomlfile" ]) == " UnicodeBox.toml"
98103
99- activate_and_run (project_dir, """
100- using Test
101- using TerminalClock, Dates
102- dt = DateTime(2021, 11, 15, 12, 34, 56, 7)
103- str = clock(dt)
104- txt = joinpath("references", "UnicodeBox", "clock.txt")
105- @test str == join(readlines(txt), "\n ")
104+ activate_and_run (
105+ project_dir,
106+ """
107+ using Test
108+ using TerminalClock, Dates
109+ dt = DateTime(2021, 11, 15, 12, 34, 56, 7)
110+ str = clock(dt)
111+ txt = joinpath("references", "UnicodeBox", "clock.txt")
112+ @test str == join(readlines(txt), "\n ")
106113
107- t = Time(12, 34, 56, 789)
108- str = stopwatch(t)
109- txt = joinpath("references", "UnicodeBox", "stopwatch.txt")
110- @test str == join(readlines(txt), "\n ")
111- """ )
114+ t = Time(12, 34, 56, 789)
115+ str = stopwatch(t)
116+ txt = joinpath("references", "UnicodeBox", "stopwatch.txt")
117+ @test str == join(readlines(txt), "\n ")
118+ """ ,
119+ )
112120
113121 # test for clear_dials
114- activate_and_run (project_dir, """
115- using TerminalClock
116- TerminalClock.clear_dials()
117- """ )
118-
119- activate_and_run (project_dir, """
120- using Test
121- using TerminalClock, Dates
122- dt = DateTime(2021, 11, 15, 12, 34, 56, 7)
123- str = clock(dt)
124- txt = joinpath("references", "ASCII", "clock.txt")
125- @test str == join(readlines(txt), "\n ")
126-
127- t = Time(12, 34, 56, 789)
128- str = stopwatch(t)
129- txt = joinpath("references", "ASCII", "stopwatch.txt")
130- @test str == join(readlines(txt), "\n ")
131- """ )
122+ activate_and_run (
123+ project_dir,
124+ """
125+ using TerminalClock
126+ TerminalClock.clear_dials()
127+ """ ,
128+ )
129+
130+ activate_and_run (
131+ project_dir,
132+ """
133+ using Test
134+ using TerminalClock, Dates
135+ dt = DateTime(2021, 11, 15, 12, 34, 56, 7)
136+ str = clock(dt)
137+ txt = joinpath("references", "ASCII", "clock.txt")
138+ @test str == join(readlines(txt), "\n ")
139+
140+ t = Time(12, 34, 56, 789)
141+ str = stopwatch(t)
142+ txt = joinpath("references", "ASCII", "stopwatch.txt")
143+ @test str == join(readlines(txt), "\n ")
144+ """ ,
145+ )
132146 end # with_temp_depot
133- end
147+ end
0 commit comments