Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed May 26, 2019
1 parent 85b0409 commit 532c1cf
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
12 changes: 12 additions & 0 deletions sample/CustomObjPath/CustomObjPath.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions sample/CustomObjPath/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>foo/bar/obj</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions sample/CustomObjPath/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// issue #58: project.assets.json not found when a custom IntermediateOutputPath is used.

open System

[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code
13 changes: 13 additions & 0 deletions sample/CustomOutputPath/CustomOutputPath.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputPath>foo/bar</OutputPath>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions sample/CustomOutputPath/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// issue #58
// Project cracking succeeds, but target dll path is not extracted from the msbuild project.

open System

[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code
4 changes: 3 additions & 1 deletion scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ dotnet restore sample/ReferenceCSharp/ReferenceCSharp.fsproj
dotnet restore sample/Signature/Signature.fsproj
dotnet restore sample/SlnReferences/ReferencedProject.fsproj
dotnet restore sample/TemplateParams/TemplateParams.fsproj
dotnet restore sample/CustomObjPath/CustomObjPath.fsproj
dotnet restore sample/CustomOutputPath/CustomOutputPath.fsproj
# These need to be built, not restored
dotnet build sample/CSharpProject/CSharpProject.csproj
dotnet build sample/CSharpProject.AssemblyName/CSharpProject.AssemblyName.csproj
dotnet build sample/CSharpProject.AssemblyName/CSharpProject.AssemblyName.csproj
16 changes: 15 additions & 1 deletion tests/ProjectCracker.Tests/ProjectCrackerTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,18 @@ let ``build unbuilt project``() =
let cracked = ProjectCracker.crack(fsproj)
if cracked.error.IsSome then Assert.Fail(cracked.error.Value)
CollectionAssert.AreEquivalent(["NotBuilt.fs"], [for f in cracked.sources do yield f.Name])
CollectionAssert.IsNotEmpty(cracked.packageReferences)
CollectionAssert.IsNotEmpty(cracked.packageReferences)

[<Test>]
let ``crack a project file with custom IntermediateOutputPath`` () =
let fsproj = Path.Combine [|projectRoot.FullName; "sample"; "CustomObjPath"; "CustomObjPath.fsproj" |] |> FileInfo
let cracked = ProjectCracker.crack(fsproj)
Assert.True(cracked.error.IsNone)

[<Test>]
let ``crack a project file with custom OutputPath`` () =
let fsproj = Path.Combine [|projectRoot.FullName; "sample"; "CustomOutputPath"; "CustomOutputPath.fsproj" |] |> FileInfo
let cracked = ProjectCracker.crack(fsproj)
Assert.AreEqual("bar", cracked.target.Directory.Name)
Assert.AreEqual("foo", cracked.target.Directory.Parent.Name)

0 comments on commit 532c1cf

Please sign in to comment.