-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUtils.fs
45 lines (39 loc) · 2.07 KB
/
Utils.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Utils
open AVPRIndex
open AVPRIndex.Domain
open Xunit
open System
open System.IO
open Fake.DotNet
type Assert with
static member ScriptRuns (args: string []) (scriptPath: string)=
let args = Array.concat [|[|scriptPath|]; args|]
//let outPath = Path.GetDirectoryName scriptPath
let result =
DotNet.exec
(fun p ->
{
p with
RedirectOutput = true
PrintRedirectedOutput = true
}
)
"fsi"
(args |> String.concat " ")
//let packageName = Path.GetFileNameWithoutExtension(scriptPath)
//let outputFolder = Path.Combine([|outPath; ".arc-validate-results"; packageName|])
//Assert.True(Directory.Exists(outputFolder))
//Assert.True(File.Exists(Path.Combine(outputFolder,"badge.svg")))
//Assert.True(File.Exists(Path.Combine(outputFolder,"validation_report.xml")))
//Assert.True(File.Exists(Path.Combine(outputFolder,"validation_summary.json")))
Assert.Equal(result.ExitCode, 0)
Assert.Empty(result.Errors)
static member ContainsFrontmatter (script: string) =
let containsCommentFrontmatter = script.StartsWith(Frontmatter.frontMatterCommentStart, StringComparison.Ordinal) && script.Contains(Frontmatter.frontMatterCommentEnd)
let containsBindingFrontmatter = script.StartsWith(Frontmatter.frontmatterBindingStart, StringComparison.Ordinal) && script.Contains(Frontmatter.frontmatterBindingEnd)
Assert.True(containsCommentFrontmatter || containsBindingFrontmatter)
static member FileNameValid(path:string) =
let fileName = Path.GetFileName(path)
let folderName = Path.GetDirectoryName(path) |> Path.GetFileName
let pattern = sprintf @"^%s@%s.fsx$" folderName AVPRIndex.Globals.SEMVER_REGEX_PATTERN[1.. (AVPRIndex.Globals.SEMVER_REGEX_PATTERN.Length - 2)] // first and last characters of that regex are start/end signifiers
Assert.Matches(pattern, fileName)