Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
fsautocomplete FAKE support for Win/Unix
Browse files Browse the repository at this point in the history
* Build
* Run unit tests
* Run integration tests
* Cannot yet run emacs tests
  • Loading branch information
rneatherway committed Oct 2, 2014
1 parent 3a28e8c commit b395c2d
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 274 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Expand Up @@ -18,15 +18,15 @@ repository/*
=======
*~
pack/*
lib/NUnit.*
lib/FsUnit.*
lib/NUnit*
lib/FsUnit

FSharp.AutoComplete/test/integration/RawIdTest/FSharp.Data
FSharp.AutoComplete/test/integration/RawIdTest/Zlib.Portable
FSharp.AutoComplete/test/integration/RawIdTest/DesignTimeURIs/
FSharp.AutoComplete/test/integration/RawIdTest/FreebaseSchema/
FSharp.AutoComplete/test/integration/RawIdTest/WorldBankSchema/
FSharp.AutoComplete/test/unit/TestResult.xml
FSharp.AutoComplete/test/unit/build
FSharp.AutoComplete/packages

# Emacs
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -15,9 +15,9 @@ install:
- sudo apt-get install -yq fsharp

script:
- make -C FSharp.AutoComplete
- make -C FSharp.AutoComplete unit-test
- make -C FSharp.AutoComplete integration-test
- FSharp.AutoComplete/fake BuildDebug
- FSharp.AutoComplete/fake UnitTest
- FSharp.AutoComplete/fake IntegrationTest
- make -C emacs test
- make -C emacs integration-test
- make -C emacs check-compile
Expand Down
111 changes: 111 additions & 0 deletions FSharp.AutoComplete/build.fsx
@@ -0,0 +1,111 @@
// include Fake lib
#r @"packages/FAKE/tools/FakeLib.dll"
open Fake
open System.IO
open System.Text.RegularExpressions

Target "RestorePackages" (fun _ ->
"packages.config"
|> RestorePackage (fun p ->
{ p with
ToolPath = "../lib/nuget/NuGet.exe" })
)

let buildDir = "./bin/Debug/"
let buildReleaseDir = "./bin/Release/"
let unitTestDir = "./test/unit/"
let unitTestBuildDir = unitTestDir + "build"
let integrationTestDir = "./test/integration/"

Target "BuildDebug" (fun _ ->
MSBuildDebug buildDir "Build" ["./FSharp.AutoComplete.fsproj"]
|> Log "Build-Output: "
)

Target "BuildRelease" (fun _ ->
MSBuildRelease buildReleaseDir "Build" ["./FSharp.AutoComplete.fsproj"]
|> Log "Build-Output: "
)

Target "BuildEmacs" (fun _ ->
MSBuildDebug "../emacs/bin" "Build" ["./FSharp.AutoComplete.fsproj"]
|> Log "Build-Output: "
)

Target "BuildUnitTest" (fun _ ->
!! (unitTestDir + "/*/*.fsproj")
|> MSBuildDebug unitTestBuildDir "Build"
|> Log "TestBuild-Output: "
)

Target "UnitTest" (fun _ ->
!! (unitTestBuildDir + "/*Tests.dll")
|> NUnit (fun p ->
{p with
DisableShadowCopy = true
Framework = "v4.0.30319"
ToolName = "nunit-console-x86.exe"
OutputFile = unitTestBuildDir + "/TestResults.xml"})
)

let integrationTests =
!! (integrationTestDir + "/**/*Runner.fsx")

let runIntegrationTest (fn: string) : bool =
let dir = Path.GetDirectoryName fn

tracefn "Running FSIHelper '%s', '%s', '%s'" FSIHelper.fsiPath dir fn
let b, msgs = FSIHelper.executeFSI dir fn []
if not b then
for msg in msgs do
traceError msg.Message

// Normalize output files so that a simple
// `git diff` will be clean if the tests passed.
for fn in !! (dir + "/*.txt") do
let lines = File.ReadAllLines fn
for i in [ 0 .. lines.Length - 1 ] do
lines.[i] <- Regex.Replace(lines.[i],
"/.*?FSharp.AutoComplete/test/(.*?(\"|$))",
@"<absolute path removed>/test/$1")

File.WriteAllLines (fn, lines)
b

Target "IntegrationTest" (fun _ ->
let runOk =
[ for i in integrationTests do
yield runIntegrationTest i ]
|> Seq.forall id
if not runOk then
failwith "Integration tests did not run successfully"
else

let ok, out, err =
Git.CommandHelper.runGitCommand
"."
("diff --exit-code " + integrationTestDir)
if not ok then
trace (toLines out)
failwithf "Integration tests failed:\n%s" err
)

Target "Test" id
Target "All" id

"RestorePackages"
==> "BuildUnitTest"
==> "UnitTest"

"RestorePackages"
==> "BuildDebug"
==> "IntegrationTest"

"UnitTest" ==> "Test"
"IntegrationTest" ==> "Test"

"BuildDebug" ==> "All"
"Test" ==> "All"

RunTargetOrDefault "BuildDebug"

18 changes: 18 additions & 0 deletions FSharp.AutoComplete/fake
@@ -0,0 +1,18 @@
#!/bin/bash

cd `dirname $0`

FAKE="packages/FAKE/tools/FAKE.exe"

if [[ ! -e ~/.config/.mono/certs ]];
then
mozroots --import --sync --quiet
fi

if [[ ! -e $FAKE ]];
then
mono ../lib/nuget/NuGet.exe "Install" "FAKE" "-OutputDirectory" "packages" "-ExcludeVersion"
fi

mono $FAKE "$@"

18 changes: 18 additions & 0 deletions FSharp.AutoComplete/fake.cmd
@@ -0,0 +1,18 @@
@echo off

pushd %~dp0

IF EXIST packages\FAKE\tools\Fake.exe GOTO FAKEINSTALLED

"..\lib\nuget\NuGet.exe" "install" "FAKE" "-OutputDirectory" "packages" "-ExcludeVersion" "-Prerelease"

:FAKEINSTALLED

SET TARGET="All"

IF NOT [%1]==[] (set TARGET="%1")

"packages\FAKE\tools\Fake.exe" "build.fsx" "target=%TARGET%"

popd

7 changes: 5 additions & 2 deletions FSharp.AutoComplete/packages.config
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Compiler.Service" version="0.0.62" targetFramework="net40" />
</packages>
<package id="FSUnit" version="1.3.0.1" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="NUnit.Runners" version="2.6.3" targetFramework="net40" />
</packages>
Expand Up @@ -16,7 +16,6 @@ let p = new FSharpAutoCompleteWrapper()
p.parse "Script.fsx"
p.completion "Script.fsx" 6 16
p.completion "Script.fsx" 6 15
p.completion "Script.fsx" 6 14
p.tooltip "Script.fsx" 6 13
p.tooltip "Script.fsx" 6 14
p.tooltip "Script.fsx" 6 15
Expand Down

0 comments on commit b395c2d

Please sign in to comment.