Skip to content

Commit 5fe083c

Browse files
committed
Rename writeLog to a trace (left writeLog compatibility)
1 parent 7f94a47 commit 5fe083c

File tree

15 files changed

+85
-85
lines changed

15 files changed

+85
-85
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build/
66
testrunner/
77
[Oo]bj/
88
[Bb]in/
9+
[Bb]ackup/
910
_ReSharper*/
1011
_UpgradeReport*
1112

XakeLibTests/ActionTests.fs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
namespace XakeLibTests
22

3-
open System.IO
4-
open System.Collections.Generic
53
open NUnit.Framework
64

75
open Xake
86

97
[<TestFixture>]
108
type ``action block allows``() =
119

12-
let MakeDebugOptions() =
13-
let errorlist = new System.Collections.Generic.List<string>() in
14-
{ExecOptions.Default with FailOnError = true; CustomLogger = CustomLogger ((=) Level.Error) errorlist.Add; FileLog = ""},errorlist
15-
10+
let makeStringList() = new System.Collections.Generic.List<string>()
1611
let DebugOptions =
1712
{ExecOptions.Default with FailOnError = true; FileLog = ""}
1813

19-
[<Test (Description = "Verifies we could use logging from inside action block")>]
20-
member test.Simple() =
14+
[<Test>]
15+
member __.``executes the body``() =
2116

2217
let wasExecuted = ref false
2318

@@ -29,12 +24,12 @@ type ``action block allows``() =
2924

3025
Assert.IsTrue(!wasExecuted)
3126

32-
[<Test (Description = "Verifies simple statements")>]
33-
member test.Logging() =
27+
[<Test>]
28+
member __.``execution is ordered``() =
3429

3530
let wasExecuted = ref false
3631

37-
let errorlist = new System.Collections.Generic.List<string>()
32+
let errorlist = makeStringList()
3833
let note = errorlist.Add
3934

4035
do xake DebugOptions {
@@ -50,12 +45,12 @@ type ``action block allows``() =
5045
Assert.IsTrue(!wasExecuted)
5146
Assert.That(errorlist, Is.EquivalentTo(["1"; "2"; "3"]))
5247

53-
[<Test (Description = "Verifies do!")>]
54-
member test.``do! async op``() =
48+
[<Test>]
49+
member __.``allows async operations``() =
5550

5651
let wasExecuted = ref false
5752

58-
let errorlist = new System.Collections.Generic.List<string>()
53+
let errorlist = makeStringList()
5954
let note = errorlist.Add
6055

6156
do xake DebugOptions {
@@ -73,11 +68,11 @@ type ``action block allows``() =
7368
Assert.That(errorlist, Is.EqualTo(["1"; "2"; "3"; "4"]))
7469

7570
[<Test>]
76-
member test.``do! action``() =
71+
member __.``do! action``() =
7772

7873
let wasExecuted = ref false
7974

80-
let errorlist = new System.Collections.Generic.List<string>()
75+
let errorlist = makeStringList()
8176
let note = errorlist.Add
8277

8378
let noteAction t = action {do note t}
@@ -98,11 +93,11 @@ type ``action block allows``() =
9893

9994

10095
[<Test>]
101-
member test.``do! action with result ignored``() =
96+
member __.``do! action with result ignored``() =
10297

10398
let wasExecuted = ref false
10499

105-
let errorlist = new System.Collections.Generic.List<string>()
100+
let errorlist = makeStringList()
106101
let note = errorlist.Add
107102

108103
let testee t =
@@ -127,9 +122,9 @@ type ``action block allows``() =
127122

128123

129124
[<Test>]
130-
member test.``let! returning value``() =
125+
member __.``let! returning value``() =
131126

132-
let errorlist = new System.Collections.Generic.List<string>()
127+
let errorlist = makeStringList()
133128
let note = errorlist.Add
134129

135130
let testee t =
@@ -150,9 +145,9 @@ type ``action block allows``() =
150145
Assert.That(errorlist, Is.EqualTo(["1"; "2+1"; "3"] |> List.toArray))
151146

152147
[<Test>]
153-
member test.``if of various kinds``() =
148+
member __.``if of various kinds``() =
154149

155-
let errorlist = new System.Collections.Generic.List<string>()
150+
let errorlist = makeStringList()
156151
let note = errorlist.Add
157152

158153
let iif f a b =
@@ -182,9 +177,9 @@ type ``action block allows``() =
182177
Assert.That(errorlist, Is.EqualTo(["i1-t"; "i2-f"; "2"; "3"] |> List.toArray))
183178

184179
[<Test>]
185-
member test.``if without else``() =
180+
member __.``if without else``() =
186181

187-
let errorlist = new System.Collections.Generic.List<string>()
182+
let errorlist = makeStringList()
188183
let note = errorlist.Add
189184

190185
let iif f a b =
@@ -202,7 +197,7 @@ type ``action block allows``() =
202197
if s1 = "2" then
203198
do note "3"
204199

205-
for i in [1..5] do
200+
for _ in [1..5] do
206201
()
207202

208203
do note "4"
@@ -212,9 +207,9 @@ type ``action block allows``() =
212207
Assert.That(errorlist, Is.EqualTo(["i1-t"; "3"; "4"] |> List.toArray))
213208

214209
[<Test>]
215-
member test.``for and while``() =
210+
member __.``for and while``() =
216211

217-
let errorlist = new System.Collections.Generic.List<string>()
212+
let errorlist = makeStringList()
218213
let note = errorlist.Add
219214

220215
do xake DebugOptions {
@@ -226,7 +221,7 @@ type ``action block allows``() =
226221
do note "1"
227222

228223
for i in [1..3] do
229-
do! writeLog Info "%A" i
224+
do! trace Info "%A" i
230225
do note (sprintf "i=%i" i)
231226

232227
let j = ref 3
@@ -241,9 +236,9 @@ type ``action block allows``() =
241236
Assert.That(errorlist, Is.EqualTo(["1"; "i=1"; "i=2"; "i=3"; "j=3"; "j=4"; "4"] |> List.toArray))
242237

243238
[<Test; Explicit>]
244-
member test.``try catch finally``() =
239+
member __.``try catch finally``() =
245240

246-
let errorlist = new System.Collections.Generic.List<string>()
241+
let errorlist = makeStringList()
247242
let note = errorlist.Add
248243

249244
do xake DebugOptions {

XakeLibTests/FileTasksTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type ``File tasks module``() =
8585
do xake TestOptions {
8686
rules [
8787
"main" => action {
88-
do! writeLog Error "Running inside 'main' rule"
88+
do! trace Error "Running inside 'main' rule"
8989
do! need ["aaa"; "clean"]
9090
do! cp "aaa" "aaa-copy"
9191
}

XakeLibTests/MiscTests.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ type MiscTests() =
2626

2727
rules [
2828
"hello" *> fun file -> action {
29-
do! writeLog Error "Running inside 'hello' rule"
29+
do! trace Error "Running inside 'hello' rule"
3030
do! need ["hello.cs"]
3131

32-
do! writeLog Error "Rebuilding..."
32+
do! trace Error "Rebuilding..."
3333
do! Csc {
3434
CscSettings with
3535
Out = file
@@ -44,7 +44,7 @@ type MiscTests() =
4444
System.Console.WriteLine("Hello world!");
4545
}
4646
}""")
47-
do! writeLog Error "Done building 'hello.cs' rule in %A" src
47+
do! trace Error "Done building 'hello.cs' rule in %A" src
4848
needExecuteCount := !needExecuteCount + 1
4949
}
5050
]

XakeLibTests/ScriptErrorTests.fs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,77 +13,77 @@ type ``Script error handling``() =
1313
{ExecOptions.Default with FailOnError = true; CustomLogger = CustomLogger ((=) Level.Error) errorlist.Add; FileLog = ""}
1414

1515
[<SetUp>]
16-
member test.Setup() =
16+
member __.Setup() =
1717
try File.Delete("." </> ".xake") with _ -> ()
1818

1919
[<Test>]
20-
member test.``verifies executing target action``() =
20+
member __.``verifies executing target action``() =
2121

2222
let wasExecuted = ref false
2323

2424
do xake ExecOptions.Default {
2525
want (["test"])
2626
phony "test" (action {
27-
do! writeLog Info "Running inside 'test' rule"
27+
do! trace Info "Running inside 'test' rule"
2828
wasExecuted := true
2929
})
3030
}
3131

3232
Assert.IsTrue(!wasExecuted)
3333

3434
[<Test>]
35-
member test.``handles (throws exception) exception is thrown in script body``() =
35+
member __.``handles (throws exception) exception is thrown in script body``() =
3636

3737
let errorlist = new System.Collections.Generic.List<string>()
3838

3939
Assert.Throws<XakeException> (fun () ->
4040
do xake (MakeDebugOptions errorlist) {
4141
want (["test"])
4242
phony "test" (action {
43-
do! writeLog Info "Running inside 'test' rule"
43+
do! trace Info "Running inside 'test' rule"
4444
failwith "exception happens"
4545
})
4646
}) |> ignore
4747

4848
Assert.IsTrue(errorlist.Exists (fun (x:string) -> x.Contains("exception happens")))
4949

5050
[<Test>]
51-
member test.``handles exception occured in inner rule``() =
51+
member __.``handles exception occured in inner rule``() =
5252

5353
let errorlist = new System.Collections.Generic.List<string>()
5454

5555
Assert.Throws<XakeException> (fun () ->
5656
do xake (MakeDebugOptions errorlist) {
5757
want (["test"])
5858
phony "test" (action {
59-
do! writeLog Info "Running inside 'test' rule"
59+
do! trace Info "Running inside 'test' rule"
6060
do! need ["clean"]
6161
})
6262
phony "clean" (action {
63-
do! writeLog Info "Running inside 'clean' rule"
63+
do! trace Info "Running inside 'clean' rule"
6464
failwith "exception happens"
6565
})
6666
}) |> ignore
6767

6868
Assert.IsTrue(errorlist.Exists (fun (x:string) -> x.Contains("exception happens")))
6969

7070
[<Test>]
71-
member test.``fails if rule is not found``() =
71+
member __.``fails if rule is not found``() =
7272

7373
let errorlist = new List<string>()
7474

7575
Assert.Throws<XakeException> (fun () ->
7676
do xake (MakeDebugOptions errorlist) {
7777
want (["test"])
7878
phony "clean" (action {
79-
do! writeLog Info "Running inside 'clean' rule"
79+
do! trace Info "Running inside 'clean' rule"
8080
})
8181
}) |> ignore
8282

8383
Assert.IsTrue(errorlist.Exists (fun (x:string) -> x.Contains("Neither rule nor file is found")))
8484

8585
[<Test>]
86-
member test.``handles broken database``() =
86+
member __.``handles broken database``() =
8787

8888
let dbname = "." </> ".xake"
8989
File.WriteAllText (dbname, "dummy text")
@@ -94,12 +94,12 @@ type ``Script error handling``() =
9494
want (["clean"; "make"])
9595
phony "clean" (action {
9696
do! rm ["*.failbroken"]
97-
do! writeLog Info "Running inside 'clean' rule"
97+
do! trace Info "Running inside 'clean' rule"
9898
})
9999
phony "make" (action {
100100
File.WriteAllText ("1.failbroken", "abc")
101101
File.WriteAllText ("2.failbroken", "def")
102-
do! writeLog Info "Running inside 'build' rule"
102+
do! trace Info "Running inside 'build' rule"
103103
})
104104
}
105105
) |> ignore

XakeLibTests/XakeScriptTests.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ type ``Xake script``() =
2626

2727
rules [
2828
"test" => action {
29-
do! writeLog Error "Running inside 'test' rule"
29+
do! trace Error "Running inside 'test' rule"
3030
do! need ["aaa"]
3131
wasExecuted := ("test" :: !wasExecuted)
3232
}
3333
"test1" => action {
34-
do! writeLog Error "Running inside 'test1' rule"
34+
do! trace Error "Running inside 'test1' rule"
3535
do! need ["aaa"]
3636
wasExecuted := ("test1" :: !wasExecuted)
3737
}
@@ -57,7 +57,7 @@ type ``Xake script``() =
5757

5858
rules [
5959
"hlo" *> fun file -> action {
60-
do! writeLog Error "Running inside 'hlo' rule"
60+
do! trace Error "Running inside 'hlo' rule"
6161
do! need ["hlo.cs"]
6262
needExecuteCount := !needExecuteCount + 1
6363
do! Async.Sleep 2000
@@ -89,7 +89,7 @@ type ``Xake script``() =
8989
rules [
9090
// TODO want ((=) "hlo") *?> ...
9191
(fun n -> n.EndsWith("hlo")) *?> fun file -> action {
92-
do! writeLog Error "Running inside 'hlo' rule"
92+
do! trace Error "Running inside 'hlo' rule"
9393
needExecuteCount := !needExecuteCount + 1
9494
do! Async.Sleep 500
9595
}
@@ -113,7 +113,7 @@ type ``Xake script``() =
113113

114114
rules [
115115
"hello" *> fun file -> action {
116-
do! writeLog Error "Running inside 'hello' rule"
116+
do! trace Error "Running inside 'hello' rule"
117117
let! files = (!!"hello*.cs") |> getFiles
118118
do! needFiles files
119119
needExecuteCount := !needExecuteCount + 1
@@ -146,7 +146,7 @@ type ``Xake script``() =
146146
"hlo" *> fun file -> action {
147147
do! need ["hlo.cs"]
148148
let! var = getEnv("TTT")
149-
do! writeLog Command "Running inside 'hlo' rule with var:%A" var
149+
do! trace Command "Running inside 'hlo' rule with var:%A" var
150150
needExecuteCount := !needExecuteCount + 1
151151
do! Async.Sleep 2000
152152
File.WriteAllText(file.FullName, "")

core/CommonTasks.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ module internal impl =
5656
let! ctx = getCtx()
5757
let log = ctx.Logger.Log
5858

59-
do! writeLog Level.Debug "[system] envvars: '%A'" settings.EnvVars
60-
do! writeLog Level.Debug "[system] args: '%A'" args
59+
do! trace Level.Debug "[system] envvars: '%A'" settings.EnvVars
60+
do! trace Level.Debug "[system] args: '%A'" args
6161

6262
let handleErr = log settings.ErrOutLevel "%s %s" settings.LogPrefix
6363
let handleStd = log settings.StdOutLevel "%s %s" settings.LogPrefix
@@ -78,9 +78,9 @@ open impl
7878
/// <param name="args">Command arguments.</param>
7979
let system cmd args =
8080
action {
81-
do! writeLog Info "[system] starting '%s'" cmd
81+
do! trace Info "[system] starting '%s'" cmd
8282
let! exitCode = _system SystemOptions cmd (args |> String.concat " ")
83-
do! writeLog Info "[system] сompleted '%s' exitcode: %d" cmd exitCode
83+
do! trace Info "[system] сompleted '%s' exitcode: %d" cmd exitCode
8484

8585
return exitCode
8686
}

0 commit comments

Comments
 (0)