Skip to content

Commit 84c1734

Browse files
Integration test (#39)
* added end2end integration test via FAKE * specified the MSBuild configuration in the integration test * log all of the detected branch names * give origin/dev a try * added work-around for CI servers
1 parent 283eee3 commit 84c1734

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

build.fsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,29 @@ Target "RunTests" (fun _ ->
115115
projects |> Seq.iter (runSingleProject)
116116
)
117117

118+
Target "IntegrationTests" <| fun _ ->
119+
let integrationTests = !! "./src/**/Incrementalist.Cmd.csproj"
120+
121+
let runSingleProject project =
122+
123+
let folderOnlyArgs = sprintf "run --project %s -c %s --no-build -- -b dev -l" project configuration
124+
let slnArgs = sprintf "run --project %s -c %s --no-build -- -b dev" project configuration
125+
126+
let execWithArgs args =
127+
let result = ExecProcess(fun info ->
128+
info.FileName <- "dotnet"
129+
info.WorkingDirectory <- __SOURCE_DIRECTORY__
130+
info.Arguments <- args) (TimeSpan.FromMinutes 5.0)
131+
if result <> 0 then failwithf "Incrementalist failed.%s" args
132+
133+
log "Running Incrementalist folders-only check"
134+
execWithArgs folderOnlyArgs
135+
136+
log "Running Incrementalist solution check"
137+
execWithArgs slnArgs
138+
139+
integrationTests |> Seq.iter runSingleProject
140+
118141
Target "NBench" <| fun _ ->
119142
let projects =
120143
match (isWindows) with
@@ -311,6 +334,7 @@ Target "Nuget" DoNothing
311334

312335
// all
313336
"BuildRelease" ==> "All"
337+
"IntegrationTests" ==> "All"
314338
"RunTests" ==> "All"
315339
"NBench" ==> "All"
316340
"Nuget" ==> "All"

src/Incrementalist.Cmd/Program.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,21 @@ private static async Task<int> RunIncrementalist(SlnOptions options)
9595
// validate the target branch
9696
if (!DiffHelper.HasBranch(repoResult.repo, options.GitBranch))
9797
{
98-
Console.WriteLine("Current git repository doesn't have any branch named [{0}]. Shutting down.", options.GitBranch);
99-
return -4;
98+
// workaround common CI server issues and check to see if this same branch is located
99+
// under "origin/{branchname}"
100+
options.GitBranch = $"origin/{options.GitBranch}";
101+
if (!DiffHelper.HasBranch(repoResult.repo, options.GitBranch))
102+
{
103+
Console.WriteLine("Current git repository doesn't have any branch named [{0}]. Shutting down.", options.GitBranch);
104+
Console.WriteLine("[Debug] Here are all of the currently known branches in this repository");
105+
foreach (var b in repoResult.repo.Branches)
106+
{
107+
Console.WriteLine(b.FriendlyName);
108+
}
109+
return -4;
110+
}
100111
}
101112

102-
103113
if (!string.IsNullOrEmpty(repoFolder))
104114
{
105115
if (options.ListFolders)

0 commit comments

Comments
 (0)