Skip to content

Commit 5074d22

Browse files
authored
New Rm, Cp, System tasks and massive public API cleanup (#17)
* new namespaces model for tasks * trying better DSL for Rm, Cp and Shell tasks * refactoring dotnet tasks (extract deps) * rename Action to Recipe, massive cleanup * cleanup of FileTasks module
1 parent 40b9462 commit 5074d22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1777
-1143
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ syntax: glob
33

44
# Ignore folders
55
build/
6-
testrunner/
6+
testrunner/
77
[Oo]bj/
88
[Bb]in/
99
[Bb]ackup/
@@ -30,5 +30,6 @@ packages
3030
*.swp
3131
TestResult.*
3232
.xake
33+
.vs/
3334
samples/**/*.exe
3435
samples/**/*.dll

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ install:
77
script:
88
- echo "module Xake.Const [<Literal>] let internal Version = \"$VER.$TRAVIS_BUILD_NUMBER\"" > ./core/VersionInfo.fs
99
- fsharpi build.fsx -- build test nuget-pack
10-
- fsharpi build.fsx -- nuget-pack
1110
deploy:
1211
- provider: releases
1312
file:
@@ -20,7 +19,7 @@ deploy:
2019
api-key:
2120
secure: GcNd0L3Kdyv9vTeKqDXHAfxQne8a6guWQYCiiEvQWtLwNss4foV2dD6PQ8W+J7l+ay8wLC+P3ZKxO0GiKbn5cglXTbBI9WlrHk+nrSQ/JWmaqqjZhGUlAvlek0Ko4walGfRQJPIaZ9pbnX4L4Mj+jrwQWrI1IyzZXbSBL2i2Tgo=
2221
- provider: script
23-
script: fsharpi build.fsx -- -ll Diag nuget-push
22+
script: fsharpi build.fsx -- nuget-push
2423
skip_cleanup: true
2524
on:
2625
tags: true

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"editor.wordWrap": "wordWrapColumn"
3+
"editor.wordWrap": "wordWrapColumn",
4+
"editor.wordWrapColumn": 120
45
}

XakeLibTests/ExplicitTests.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ open System.IO
44
open NUnit.Framework
55

66
open Xake
7+
open Xake.Tasks
8+
open Xake.Tasks.Dotnet
79

810
[<Explicit>]
911
[<TestCase("mono-35")>]
@@ -25,7 +27,7 @@ let ``various frameworks``(fwk:string) =
2527
src (!! "a.cs")
2628
grefs ["mscorlib.dll"; "System.dll"; "System.Core.dll"]
2729
}
28-
"a.cs" ..> writeTextFile """
30+
"a.cs" ..> writeText """
2931
class Program
3032
{
3133
public static void Main()

XakeLibTests/FileTasksCopy.fs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
module ``Copy task``
2+
3+
open NUnit.Framework
4+
5+
open Xake
6+
open Xake.Tasks
7+
8+
open System.IO
9+
10+
let TestOptions = {ExecOptions.Default with Threads = 1; Targets = ["main"]; ConLogLevel = Diag; FileLogLevel = Silent}
11+
12+
[<Test>]
13+
let ``copies single file``() =
14+
"." </> ".xake" |> File.Delete
15+
if Directory.Exists "cptgt" then
16+
Directory.Delete ("cptgt", true)
17+
18+
do xake TestOptions {
19+
rules [
20+
"main" => action {
21+
do! need ["samplefile"]
22+
do! Cp {CpArgs.Default with file = "samplefile"; todir = "cptgt"}
23+
}
24+
25+
"samplefile" ..> writeText "hello world"
26+
]
27+
}
28+
29+
Assert.True <| File.Exists ("cptgt" </> "samplefile")
30+
31+
[<Test>]
32+
let ``copies folder flatten``() =
33+
"." </> ".xake" |> File.Delete
34+
["cptgt"; "cpin"] |> List.map (fun d -> if Directory.Exists d then Directory.Delete (d, true))
35+
36+
do xake TestOptions {
37+
rules [
38+
"main" => action {
39+
do! need ["cpin/samplefile"]
40+
do! Cp {CpArgs.Default with dir = "cpin"; todir = "cptgt"; flatten = true}
41+
}
42+
43+
"cpin/samplefile" ..> writeText "hello world"
44+
]
45+
}
46+
47+
Assert.True <| File.Exists ("cptgt" </> "samplefile")
48+
49+
[<Test>]
50+
let ``copies folder no flatten``() =
51+
"." </> ".xake" |> File.Delete
52+
["cptgt"; "cpin"] |> List.map (fun d -> if Directory.Exists d then Directory.Delete (d, true))
53+
54+
do xake TestOptions {
55+
rules [
56+
"main" => action {
57+
do! need ["cpin/a/samplefile"]
58+
do! Cp {CpArgs.Default with dir = "cpin"; todir = "cptgt"; flatten = false}
59+
}
60+
61+
"cpin/a/samplefile" ..> writeText "hello world"
62+
]
63+
}
64+
65+
Assert.True <| File.Exists ("cptgt" </> "cpin" </> "a" </> "samplefile")
66+
67+
[<Test>]
68+
let ``copies fileset NO flatten``() =
69+
"." </> ".xake" |> File.Delete
70+
["cptgt"; "cpin"] |> List.map (fun d -> if Directory.Exists d then Directory.Delete (d, true))
71+
72+
do xake TestOptions {
73+
rules [
74+
"main" => action {
75+
do! need ["cpin/a/samplefile"]
76+
do! Cp {CpArgs.Default with
77+
files = (fileset {basedir "cpin"; includes "**/*"})
78+
todir = "cptgt"
79+
flatten = false
80+
}
81+
}
82+
83+
"cpin/a/samplefile" ..> writeText "hello world"
84+
]
85+
}
86+
87+
Assert.True <| File.Exists ("cptgt" </> "a" </> "samplefile")
88+
89+
[<Test>]
90+
let ``copies fileset flatten``() =
91+
"." </> ".xake" |> File.Delete
92+
["cptgt"; "cpin"] |> List.map (fun d -> if Directory.Exists d then Directory.Delete (d, true))
93+
94+
do xake TestOptions {
95+
rules [
96+
"main" => action {
97+
do! need ["cpin/a/samplefile"]
98+
do! cp {files !!"cpin/**/*"; todir "cptgt"; flatten}
99+
}
100+
101+
"cpin/a/samplefile" ..> writeText "hello world"
102+
]
103+
}
104+
105+
Assert.True <| File.Exists ("cptgt" </> "samplefile")

XakeLibTests/FileTasksRm.fs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
module ``Del(rm) task``
2+
3+
open NUnit.Framework
4+
5+
open Xake
6+
open Xake.Tasks
7+
8+
type private File = System.IO.File
9+
10+
let TestOptions = {ExecOptions.Default with Threads = 1; Targets = ["main"]; ConLogLevel = Diag; FileLogLevel = Silent}
11+
12+
13+
[<Test>]
14+
let ``Rm deletes single file``() =
15+
"." </> ".xake" |> File.Delete
16+
17+
do xake TestOptions {
18+
rules [
19+
"main" => action {
20+
do! need ["samplefile"]
21+
File.Exists "samplefile" |> Assert.True
22+
do! rm {file "samplefile"; verbose}
23+
}
24+
25+
"samplefile" ..> writeText "hello world"
26+
]
27+
}
28+
29+
File.Exists "samplefile" |> Assert.False
30+
31+
[<Test>]
32+
let ``Rm deletes files by mask``() =
33+
"." </> ".xake" |> File.Delete
34+
35+
do xake TestOptions {
36+
rules [
37+
"main" => action {
38+
do! need ["samplefile"; "samplefile1"]
39+
File.Exists "samplefile" |> Assert.True
40+
File.Exists "samplefile1" |> Assert.True
41+
42+
do! rm {file "samplefile*"}
43+
}
44+
45+
"samplefile" ..> writeText "hello world"
46+
"samplefile1" ..> writeText "hello world1"
47+
]
48+
}
49+
50+
File.Exists "samplefile" |> Assert.False
51+
File.Exists "samplefile1" |> Assert.False
52+
53+
[<Test>]
54+
let ``Rm deletes dir``() =
55+
"." </> ".xake" |> File.Delete
56+
57+
do xake TestOptions {
58+
rules [
59+
"main" => recipe {
60+
do! need ["a/samplefile"; "a/b/samplefile1"]
61+
File.Exists ("a" </> "b" </> "samplefile1") |> Assert.True
62+
63+
do! rm {dir "a"}
64+
}
65+
66+
"a/samplefile" ..> writeText "hello world"
67+
"a/b/samplefile1" ..> writeText "hello world1"
68+
]
69+
}
70+
71+
System.IO.Directory.Exists "a" |> Assert.False
72+
73+
74+
[<Test>]
75+
let ``Rm deletes fileset``() =
76+
"." </> ".xake" |> File.Delete
77+
78+
do xake TestOptions {
79+
rules [
80+
"main" => recipe {
81+
do! need ["samplefile"; "samplefile1"]
82+
do! rm {
83+
files (fileset {
84+
includes "samplefile*"
85+
})
86+
}
87+
}
88+
89+
"samplefile*" ..> writeText "hello world"
90+
]
91+
}
92+
93+
File.Exists "samplefile" |> Assert.False
94+
File.Exists "samplefile1" |> Assert.False

XakeLibTests/FileTasksTests.fs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
open NUnit.Framework
44

55
open Xake
6-
open Xake.FileTasks
6+
open Xake.Tasks
77

88
type private File = System.IO.File
99

@@ -20,10 +20,10 @@ let ``allows delete file``() =
2020
execCount := !execCount + 1
2121
do! need ["samplefile"]
2222
File.Exists "samplefile" |> Assert.True
23-
do! rm ["samplefile"]
23+
do! rm {file "samplefile"}
2424
}
2525

26-
"samplefile" ..> writeTextFile "hello world"
26+
"samplefile" ..> writeText "hello world"
2727
]
2828
}
2929

@@ -40,11 +40,11 @@ let ``allows delete file by mask``() =
4040
"main" => action {
4141
do! need ["$$1"; "$$2"]
4242
File.Exists "$$2" |> Assert.True
43-
do! rm ["$$*"]
43+
do! rm {file "$$*"}
4444
execCount := !execCount + 1
4545
}
4646

47-
"$$*" ..> writeTextFile "hello world"
47+
"$$*" ..> writeText "hello world"
4848
]
4949
}
5050

@@ -59,10 +59,11 @@ let ``allows to delete by several masks``() =
5959
"main" => action {
6060
do! need ["$aa"; "$bb"]
6161
File.Exists ("$bb") |> Assert.True
62-
do! rm ["$aa"; "$b*"]
62+
do! rm {file "$aa"}
63+
do! rm {file "$b*"}
6364
}
6465

65-
"$*" ..> writeTextFile "hello world"
66+
"$*" ..> writeText "hello world"
6667
]
6768
}
6869

@@ -79,8 +80,8 @@ let ``supports simple file copy``() =
7980
do! copyFile "aaa" "aaa-copy"
8081
}
8182

82-
"clean" => rm ["aaa-copy"]
83-
"aaa" ..> writeTextFile "hello world"
83+
"clean" => rm {file "aaa-copy"}
84+
"aaa" ..> writeText "hello world"
8485
]
8586
}
8687

XakeLibTests/FilesetTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let ``could search and return directories``() =
8282
Assert.That (files |> List.map File.getFileName, Is.EquivalentTo (List.toSeq ["bak"; "rpt"; "jparsec"]))
8383

8484
[<Test>]
85-
let ``privides builder computation``() =
85+
let ``provides builder computation``() =
8686
let fileset = fileset {
8787
basedir @"c:\rpt"
8888

0 commit comments

Comments
 (0)