Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Byrd committed Mar 16, 2018
1 parent f2e7964 commit f15a773
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 16 deletions.
10 changes: 0 additions & 10 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,5 @@ IF NOT EXIST build.fsx (
.paket\paket.exe update
packages\build\FAKE\tools\FAKE.exe init.fsx
)
pushd Content\
call build.cmd
if errorlevel 1 (
exit /b %errorlevel%
)
call build.cmd Clean
if errorlevel 1 (
exit /b %errorlevel%
)
popd

packages\build\FAKE\tools\FAKE.exe build.fsx %*
73 changes: 72 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.UserInputHelper
open System
open System.IO

let release = LoadReleaseNotes "RELEASE_NOTES.md"
let srcGlob = "*.csproj"
Expand Down Expand Up @@ -46,6 +47,75 @@ Target "DotnetPack" (fun _ ->
)
)

let dispose (disposable : #IDisposable) = disposable.Dispose()
[<AllowNullLiteral>]
type DisposableDirectory (directory : string) =
do
tracefn "Created disposable directory %s" directory
static member Create() =
let tempPath = IO.Path.Combine(IO.Path.GetTempPath(), Guid.NewGuid().ToString("n"))
IO.Directory.CreateDirectory tempPath |> ignore

new DisposableDirectory(tempPath)
member x.Directory = directory
member x.DirectoryInfo = IO.DirectoryInfo(directory)

interface IDisposable with
member x.Dispose() =
tracefn "Deleting directory %s" directory
IO.Directory.Delete(x.Directory,true)

type DisposeablePushd (directory : string) =
do FileUtils.pushd directory
member x.Directory = directory
member x.DirectoryInfo = IO.DirectoryInfo(directory)
interface IDisposable with
member x.Dispose() =
FileUtils.popd()


Target "IntegrationTests" (fun _ ->
// uninstall current MiniScaffold
DotNetCli.RunCommand id
"new -u MiniScaffold"
// install from dist/
DotNetCli.RunCommand id
<| sprintf "new -i dist/MiniScaffold.%s.nupkg" release.NugetVersion

[
"-n MyCoolLib --githubUsername CoolPersonNo2", "DotnetPack"
]
|> Seq.iter(fun (param, testTarget) ->
use directory = DisposableDirectory.Create()
use pushd1 = new DisposeablePushd(directory.Directory)
DotNetCli.RunCommand (fun commandParams ->
{ commandParams with WorkingDir = directory.Directory}
)
<| sprintf "new mini-scaffold -lang F# %s" param
use pushd2 =
directory.DirectoryInfo.GetDirectories ()
|> Seq.head
|> string
|> fun x -> new DisposeablePushd(x)

let ok =
ProcessHelper.execProcess (fun psi ->
psi.WorkingDirectory <- Environment.CurrentDirectory
if isMono then
psi.FileName <- "./build.sh"
psi.Arguments <- sprintf "%s -nc" testTarget
else
psi.FileName <- Environment.CurrentDirectory @@ "build.cmd"
psi.Arguments <- sprintf "%s -nc" testTarget

) (TimeSpan.FromMinutes(5.))

if not ok then
failwithf "Intregration test failed with params %s" param
)

)

Target "Publish" (fun _ ->
Paket.Push(fun c ->
{ c with
Expand All @@ -72,7 +142,8 @@ Target "Release" (fun _ ->
"Clean"
==> "DotnetRestore"
==> "DotnetPack"
==> "IntegrationTests"
==> "Publish"
==> "Release"

RunTargetOrDefault "DotnetPack"
RunTargetOrDefault "IntegrationTests"
5 changes: 0 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,5 @@ then
run $PAKET_EXE restore
fi

# build template
pushd Content/
./build.sh
./build.sh Clean
popd

run $FAKE_EXE "$@" $FSIARGS $FSIARGS2 build.fsx

0 comments on commit f15a773

Please sign in to comment.