Skip to content

Commit 7fe56ba

Browse files
Run test both in debug and production mode
1 parent e549bb1 commit 7fe56ba

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

build.fsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ let buildCompilerJs testLocal =
9898
let buildStandalone() =
9999
let projectDir = "src/fable-standalone"
100100
let libraryDir = "build/fable-library"
101-
cleanDirs [projectDir </> "dist"]
102-
buildLibrary()
101+
if pathExists libraryDir |> not then
102+
buildLibrary()
103103

104+
cleanDirs [projectDir </> "dist"]
104105
// bundle.min.js
105106
buildWebpack projectDir
106107
fileSizeInBytes (projectDir </> "dist/bundle.min.js") / 1000
@@ -135,20 +136,27 @@ let test() =
135136
if pathExists "build/fable-library" |> not then
136137
buildLibrary()
137138

138-
cleanDirs ["build/tests"]
139-
buildSplitter "tests"
140-
run "npx mocha build/tests --reporter dot -t 10000"
141-
runInDir "tests/Main" "dotnet run"
139+
let runTestsInNodeWithArgs args =
140+
cleanDirs ["build/tests"]
141+
buildSplitterWithArgs "tests" args
142+
run "npx mocha build/tests --reporter dot -t 10000"
143+
144+
runTestsInNodeWithArgs "--debug"
145+
runTestsInNodeWithArgs ""
142146
runInDir "tests/Fable.Cli.Test" "dotnet run"
143147

144148
if envVarOrNone "APPVEYOR" |> Option.isSome then
145149
buildStandalone()
146150
// Test fable-compiler-js locally
147-
buildCompilerJs true
148-
run "node src/fable-compiler-js tests/Main/Fable.Tests.fsproj build/tests-js --commonjs"
149-
run "npx mocha build/tests-js --reporter dot -t 10000"
150-
// runInDir "src/fable-compiler-js/test" "node .. test_script.fsx --commonjs"
151-
// runInDir "src/fable-compiler-js/test" "node bin/test_script.js"
151+
// Not sure why, but building fable-compiler-js immediately after fable-standalone
152+
// is failing, let's wait a couple of seconds to see if that helps
153+
JS.setTimeout (fun () ->
154+
buildCompilerJs true
155+
run "node src/fable-compiler-js tests/Main/Fable.Tests.fsproj build/tests-js --commonjs"
156+
run "npx mocha build/tests-js --reporter dot -t 10000"
157+
// runInDir "src/fable-compiler-js/test" "node .. test_script.fsx --commonjs"
158+
// runInDir "src/fable-compiler-js/test" "node bin/test_script.js"
159+
) 2000 |> ignore
152160

153161

154162
let coverage() =

src/fable-compiler-js/src/ProjectParser.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ let parseCompilerOptions projectText =
3030
// get conditional defines
3131
let defines =
3232
Regex.Matches(projectText, @"<DefineConstants[^>]*>([^<]*)<\/DefineConstants[^>]*>")
33+
|> Seq.cast<Match>
3334
|> Seq.collect (fun m -> m.Groups.[1].Value.Split(';'))
3435
|> Seq.append ["FABLE_COMPILER"]
3536
|> Seq.map (fun s -> s.Trim())
@@ -40,6 +41,7 @@ let parseCompilerOptions projectText =
4041
// get disabled warnings
4142
let nowarns =
4243
Regex.Matches(projectText, @"<NoWarn[^>]*>([^<]*)<\/NoWarn[^>]*>")
44+
|> Seq.cast<Match>
4345
|> Seq.collect (fun m -> m.Groups.[1].Value.Split(';'))
4446
|> Seq.map (fun s -> s.Trim())
4547
|> Seq.distinct
@@ -49,6 +51,7 @@ let parseCompilerOptions projectText =
4951
// get warnings as errors
5052
let warnAsErrors =
5153
Regex.Matches(projectText, @"<WarningsAsErrors[^>]*>([^<]*)<\/WarningsAsErrors[^>]*>")
54+
|> Seq.cast<Match>
5255
|> Seq.collect (fun m -> m.Groups.[1].Value.Split(';'))
5356
|> Seq.map (fun s -> s.Trim())
5457
|> Seq.distinct
@@ -58,6 +61,7 @@ let parseCompilerOptions projectText =
5861
// get other flags
5962
let otherFlags =
6063
Regex.Matches(projectText, @"<OtherFlags[^>]*>([^<]*)<\/OtherFlags[^>]*>")
64+
|> Seq.cast<Match>
6165
|> Seq.collect (fun m -> m.Groups.[1].Value.Split(' '))
6266
|> Seq.map (fun s -> s.Trim())
6367
|> Seq.distinct
@@ -105,6 +109,7 @@ let parseProjectFile projectFileName =
105109
// get project references
106110
let projectRefs =
107111
Regex.Matches(projectText, @"<ProjectReference\s+[^>]*Include\s*=\s*(""[^""]*|'[^']*)")
112+
|> Seq.cast<Match>
108113
|> Seq.map (fun m -> m.Groups.[1].Value.TrimStart('"').TrimStart(''').Trim().Replace("\\", "/"))
109114
|> Seq.toArray
110115

@@ -118,6 +123,7 @@ let parseProjectFile projectFileName =
118123
let sourceFilesRegex = @"<Compile\s+[^>]*Include\s*=\s*(""[^""]*|'[^']*)"
119124
let sourceFiles =
120125
Regex.Matches(projectText, sourceFilesRegex)
126+
|> Seq.cast<Match>
121127
|> Seq.map (fun m -> m.Groups.[1].Value.TrimStart('"').TrimStart(''').Trim().Replace("\\", "/"))
122128
|> Seq.toArray
123129

src/fable-compiler-js/src/app.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ let getMetadataDir(): string = importDefault "fable-metadata"
1616
let getFableLibDir(): string = importMember "./util.js"
1717
#endif
1818

19+
[<Emit("process.argv.slice(2)")>]
20+
let argv: string[] = jsNative
21+
1922
let references = Fable.Standalone.Metadata.references_core
2023
let metadataPath = getMetadataDir().TrimEnd('\\', '/') + "/" // .NET BCL binaries (metadata)
2124

@@ -127,10 +130,10 @@ let parseArguments (argv: string[]) =
127130
run opts projectFileName outDir
128131
| _ -> printfn "%s" usage
129132

130-
[<EntryPoint>]
131-
let main argv =
133+
let main() =
132134
try
133135
parseArguments argv
134136
with ex ->
135137
printfn "Error: %A" ex.Message
136-
0
138+
139+
main()

src/fable-compiler-js/src/fable-compiler-js.fsproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
<DefineConstants>$(DefineConstants);FABLE_COMPILER</DefineConstants>
65
</PropertyGroup>
76

87
<ItemGroup>

src/fable-library/System.Text.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ type StringBuilder(value: string, capacity: int) =
77
new (value: string) = StringBuilder(value, 16)
88
new () = StringBuilder(null, 16)
99
member x.Append(s: string) = buf.Add(s); x
10+
member x.Append(c: char) = buf.Add(string c); x
1011
member x.AppendFormat(fmt: string, o: obj) = buf.Add(System.String.Format(fmt, o)); x
1112
override __.ToString() = System.String.Concat(buf)

0 commit comments

Comments
 (0)