Skip to content

Commit bab8365

Browse files
committed
template testing
1 parent 1a6726c commit bab8365

File tree

14 files changed

+133
-366
lines changed

14 files changed

+133
-366
lines changed

.nuget/NuGet.config

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
5+
<add key="myget.org" value="https://www.myget.org/F/oxyplot" />
6+
</packageSources>
7+
</configuration>
8+

.nuget/NuGet.exe

4.83 MB
Binary file not shown.

build.fsx

+55-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ open Fake
1515
// --------------------------------------------------------------------------------------
1616

1717
let project = "FSharp.TypeProviders.SDK"
18-
let authors = ["Tomas Petricek"; "Gustavo Guerra"; "Michael Newton"; "Don Syme" ]
18+
let authors = ["FSharp.TypeProviders.SDK contributors" ]
1919
let summary = "Helper code and examples for getting started with Type Providers"
2020
let description = """
2121
The F# Type Provider SDK provides utilities for authoring type providers."""
@@ -25,6 +25,7 @@ let gitHome = "https://github.com/fsprojects"
2525
let gitName = "FSharp.TypeProviders.SDK"
2626

2727
let config = "Release"
28+
let outputPath = __SOURCE_DIRECTORY__ + "/bin"
2829

2930
// Read release notes & version info from RELEASE_NOTES.md
3031
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
@@ -45,6 +46,10 @@ let exec p args =
4546
printfn "Executing %s %s" p args
4647
Shell.Exec(p, args) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d
4748

49+
let execIn dir p args =
50+
printfn "Executing %s %s in %s" p args dir
51+
Shell.Exec(p, args, dir=dir) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d
52+
4853
let pullRequest =
4954
match getBuildParamOrDefault "APPVEYOR_PULL_REQUEST_NUMBER" "" with
5055
| "" ->
@@ -142,12 +147,57 @@ Target "RunTests" (fun _ ->
142147
)
143148

144149
Target "Pack" (fun _ ->
145-
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "src/FSharp.TypeProviders.SDK.fsproj"; ToolPath = getSdkPath() })
146-
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/BasicProvider/BasicProvider.fsproj"; ToolPath = getSdkPath() })
147-
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/ComboProvider/ComboProvider.fsproj"; ToolPath = getSdkPath() })
148-
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/StressProvider/StressProvider.fsproj"; ToolPath = getSdkPath() })
150+
DotNetCli.Pack (fun p -> { p with Configuration = config;
151+
Project = "src/FSharp.TypeProviders.SDK.fsproj";
152+
ToolPath = getSdkPath(); OutputPath = outputPath;
153+
AdditionalArgs= [ sprintf "/p:PackageVersion=%s" release.NugetVersion;
154+
sprintf "/p:ReleaseNotes=\"%s\"" (String.concat " " release.Notes) ] })
155+
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/BasicProvider/BasicProvider.fsproj"; ToolPath = getSdkPath(); OutputPath = outputPath })
156+
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/ComboProvider/ComboProvider.fsproj"; ToolPath = getSdkPath(); OutputPath = outputPath })
157+
DotNetCli.Pack (fun p -> { p with Configuration = config; Project = "examples/StressProvider/StressProvider.fsproj"; ToolPath = getSdkPath(); OutputPath = outputPath })
158+
NuGetHelper.NuGetPack (fun p -> { p with WorkingDir = "templates"; OutputPath = outputPath; Version = release.NugetVersion; ReleaseNotes = toLines release.Notes}) @"templates/FSharp.TypeProviders.Templates.nuspec"
159+
)
160+
161+
Target "TestTemplatesNuGet" (fun _ ->
162+
163+
// Globally install the templates from the template nuget package we just built
164+
DotNetCli.RunCommand id ("new -i " + outputPath + "/FSharp.TypeProviders.Templates." + release.NugetVersion + ".nupkg")
165+
166+
let testAppName = "tp2" + string (abs (hash System.DateTime.Now.Ticks) % 100)
167+
CleanDir testAppName
168+
DotNetCli.RunCommand id (sprintf "new typeprovider -n %s -lang F#" testAppName)
169+
170+
let pkgs = Path.GetFullPath(outputPath)
171+
// When restoring, using the build_output as a package source to pick up the package we just compiled
172+
execIn testAppName ".paket/paket.exe" "update"
173+
//DotNetCli.RunCommand id (sprintf "restore %s/%s/%s.fsproj --source https://api.nuget.org/v3/index.json --source %s" testAppName testAppName testAppName pkgs)
174+
175+
// let slash = if isUnix then "\\" else ""
176+
// for c in ["Debug"; "Release"] do
177+
// for p in ["Any CPU"; "iPhoneSimulator"] do
178+
// exec "msbuild" (sprintf "%s/%s.sln /p:Platform=\"%s\" /p:Configuration=%s /p:PackageSources=%s\"https://api.nuget.org/v3/index.json%s;%s%s\"" testAppName testAppName p c slash slash pkgs slash)
179+
DotNetCli.RunCommand (fun p -> { p with WorkingDir=testAppName }) (sprintf "build -c debug")
180+
DotNetCli.RunCommand (fun p -> { p with WorkingDir=testAppName }) (sprintf "test -c debug")
181+
182+
(* Manual steps without building nupkg
183+
dotnet pack src\FSharp.TypeProviders.SDK.fsproj /p:PackageVersion=0.0.0.99 --output bin -c release
184+
.nuget\nuget.exe pack -OutputDirectory bin -Version 0.0.0.99 templates/FSharp.TypeProviders.Templates.nuspec
185+
dotnet new -i bin/FSharp.TypeProviders.Templates.0.0.0.99.nupkg
186+
dotnet new typeprovider -n tp3 -lang:F#
187+
188+
.\build LibraryNuGet
189+
dotnet new -i templates
190+
rmdir /s /q testapp2
191+
dotnet new fabulous-app -n testapp2 -lang F#
192+
dotnet restore testapp2/testapp2/testapp2.fsproj -s build_output/
193+
dotnet new -i templates && rmdir /s /q testapp2 && dotnet new fabulous-app -n testapp2 -lang F# && dotnet restore testapp2/testapp2/testapp2.fsproj && msbuild testapp2/testapp2.Android/testapp2.Android.fsproj /t:RestorePackages && msbuild testapp2/testapp2.Android/testapp2.Android.fsproj
194+
dotnet new -i templates && rmdir /s /q testapp2 && dotnet new fabulous-app -n testapp2 -lang F# && dotnet restore testapp2/testapp2/testapp2.fsproj && msbuild testapp2/testapp2.iOS/testapp2.iOS.fsproj /t:RestorePackages && msbuild testapp2/testapp2.iOS/testapp2.iOS.fsproj
195+
dotnet new -i templates && rmdir /s /q testapp2 && dotnet new fabulous-app -n testapp2 -lang F# --CreateMacProject && dotnet restore testapp2/testapp2/testapp2.fsproj && msbuild testapp2/testapp2.macOS/testapp2.macOS.fsproj /t:RestorePackages && msbuild testapp2/testapp2.macOS/testapp2.macOS.fsproj
196+
*)
197+
149198
)
150199

200+
151201
"Clean" ==> "Pack"
152202
"Build" ==> "Examples" ==> "Pack"
153203
"Build" ==> "Examples" ==> "RunTests" ==> "Pack"

examples/BasicProvider.Tests/BasicProvider.Tests.fs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
module MyProvider.Tests
2+
module BasicProvider.Tests
33

4-
open MyProvider.Provided
4+
open BasicProvider.Provided
55
open Xunit
66

77
[<Fact>]
@@ -17,8 +17,8 @@ let ``Method with ReflectedDefinition parameter should get its name`` () =
1717
let myValue = 2
1818
Assert.Equal("myValue", MyType.NameOf(myValue))
1919

20-
type Generative2 = MyProvider.GenerativeProvider<2>
21-
type Generative4 = MyProvider.GenerativeProvider<4>
20+
type Generative2 = BasicProvider.GenerativeProvider<2>
21+
type Generative4 = BasicProvider.GenerativeProvider<4>
2222

2323
[<Fact>]
2424
let ``Can access properties of generative provider 2`` () =

src/FSharp.TypeProviders.SDK.fsproj

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
77
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9+
<Authors>FSharp.TypeProviders.SDK contributors</Authors>
10+
<PackageLicenseUrl>http://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/master/LICENSE.md</PackageLicenseUrl>
11+
<PackageProjectUrl>http://github.com/fsprojects/FSharp.TypeProviders.SDK</PackageProjectUrl>
12+
<PackageIconUrl>https://raw.githubusercontent.com/fsprojects/FSharp.TypeProviders.SDK/master/docs/files/img/logo.png</PackageIconUrl>
13+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
14+
<Description>The core implementation of an F# type provider</Description>
15+
<Copyright>Copyright 2017 FSharp.TypeProviders.SDK contributors</Copyright>
16+
<tags>F# fsharp typeprovider</tags>
917
</PropertyGroup>
1018
<ItemGroup>
1119
<Compile Include="ProvidedTypes.fsi" />

0 commit comments

Comments
 (0)