-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP fix for shell script executable bit and scaffolding for template tests #1990
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ddaca7
fix for shell script executable bit and scaffolding for tests
baronfel dbdbbff
write template tests
baronfel 5e22412
make the tests autonomous
baronfel b02b7f1
rname to fix casing
baronfel e02f56c
add a test around building a target, and one around failing on a miss…
baronfel db9327e
pull the template tests into the build pipeline
baronfel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/test/Fake.Dotnet.Cli.IntegrationTests/Fake.Dotnet.Cli.IntegrationTests.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\app\Fake.DotNet.Cli\Fake.DotNet.Cli.fsproj" /> | ||
<ProjectReference Include="..\..\app\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" /> | ||
<ProjectReference Include="..\..\app\Fake.Core.Process\Fake.Core.Process.fsproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="TemplateTests.fs" /> | ||
<Compile Include="Main.fs" /> | ||
<None Include="paket.references" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main.Tests | ||
open Expecto | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
Tests.runTestsInAssembly { defaultConfig with parallel = false } argv |
75 changes: 75 additions & 0 deletions
75
src/test/Fake.Dotnet.Cli.IntegrationTests/TemplateTests.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
module Fake.DotNet.Cli.IntegrationTests.TemplateTests | ||
|
||
open Expecto | ||
open System | ||
open System.IO | ||
|
||
open Fake.Core | ||
open Fake.DotNet | ||
open Fake.IO | ||
open Fake.IO.Globbing | ||
|
||
let templateProj = "fake-template.fsproj" | ||
let templatePackageName = "fake-template" | ||
let templateName = "fake" | ||
|
||
//TODO: add DotNetCli helpers for the `new` command | ||
|
||
let uninstallTemplate () = | ||
DotNet.exec id "new" (sprintf "-u %s" templatePackageName) | ||
|
||
let installTemplateFrom pathToNupkg = | ||
DotNet.exec id "new" (sprintf "-i %s" pathToNupkg) | ||
|
||
type BootstrapKind = | ||
| Tool | ||
| Project | ||
with override x.ToString () = match x with | Tool -> "tool" | Project -> "project" | ||
|
||
let isFAKEHelpOutput (r: ProcessResult) = | ||
r.ExitCode = 1 && r.Messages |> List.exists (fun m -> m.Contains("fake")) | ||
|
||
let shouldSucceed message (r: ProcessResult) = | ||
Expect.isTrue (r.OK || isFAKEHelpOutput r) (sprintf "%s. Messages:\n:%A" message r) | ||
|
||
let runTemplate rootDir kind = | ||
Directory.ensure rootDir | ||
let inDir = DotNet.Options.withWorkingDirectory rootDir | ||
DotNet.exec inDir "new" (sprintf "%s --bootstrap %s" templateName (string kind)) | ||
|
||
let invokeScript dir scriptName = | ||
let fullScriptPath = Path.Combine(dir, scriptName) | ||
Process.execWithResult (fun x -> x.WithWorkingDirectory(dir).WithFileName(fullScriptPath)) (System.TimeSpan.FromSeconds 60.) | ||
|> shouldSucceed "should invoke the script file" | ||
|
||
[<Tests>] | ||
let tests = | ||
// we need to (uninstall) the template, install the packed version, and then execute that template | ||
testList "Fake.DotNet.Cli.IntegrationTests.Template tests" [ | ||
// TODO: entire test list is pending because it won't run interactively, because it needs user input :-/ | ||
ptestList "can install and run the template" [ | ||
uninstallTemplate () |> shouldSucceed "should clear out preexisting templates" | ||
let templateNupkg = GlobbingPattern.create "../../template/fake-template/bin/Release/fake-template.*.nupkg" |> Seq.head | ||
installTemplateFrom templateNupkg |> shouldSucceed "should install new FAKE template" | ||
|
||
let scriptFile = | ||
if Environment.isUnix | ||
then "fake.sh" | ||
else "fake.cmd" | ||
|
||
yield test "can install a project-style template" { | ||
let tempDir = Path.Combine(Path.GetTempPath (), Path.GetRandomFileName()) | ||
Directory.ensure tempDir | ||
do runTemplate tempDir Project |> shouldSucceed "should run the template" | ||
invokeScript tempDir scriptFile | ||
} | ||
|
||
/// ignored because the .net tool install to a subdirectory is broken: https://github.com/fsharp/FAKE/pull/1989#issuecomment-396057330 | ||
yield ptest "can install a tool-style template" { | ||
let tempDir = Path.Combine(Path.GetTempPath (), Path.GetRandomFileName()) | ||
Directory.ensure tempDir | ||
do runTemplate tempDir Tool |> shouldSucceed "should run the template" | ||
invokeScript tempDir scriptFile | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
group netcore | ||
|
||
FSharp.Core | ||
NETStandard.Library | ||
Expecto |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also rename the folder in git, otherwise there will be problems (which is a bit unfortunate to do on windows as you have to temporarily rename to something else)