Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated standalone test build #3802

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,22 @@
// "type": "coreclr",
// "request": "launch",
// "preLaunchTask": "build bench-compiler",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/bin/Debug/net8.0/bench-compiler.dll",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/src/bin/Debug/net8.0/bench-compiler.dll",
// "args": ["${workspaceRoot}/../fable-test/fable-test.fsproj", "--outDir", "./out-test", "--fableLib", "./out-lib-js"],
// "cwd": "${workspaceRoot}/src/fable-standalone/test/bench-compiler",
// "stopAtEntry": false,
// "console": "internalConsole"
// },
// {
// "name": "Run bench-compiler (native)",
// "type": "lldb",
// "request": "launch",
// "preLaunchTask": "publish bench-compiler",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/src/bin/Debug/net8.0/linux-x64/native/bench-compiler",
// "args": ["${workspaceRoot}/../fable-test/fable-test.fsproj", "--outDir", "./out-test", "--fableLib", "./out-lib-js"],
// "cwd": "${workspaceRoot}/src/fable-standalone/test/bench-compiler",
// "console": "internalConsole"
// },
{
"name": "Fable.Cli - fable-library-dart",
"type": "coreclr",
Expand Down
18 changes: 17 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,23 @@
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"src/fable-standalone/test/bench-compiler"
"src/fable-standalone/test/bench-compiler/src"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish bench-compiler",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"src/fable-standalone/test/bench-compiler/src",
"--configuration",
"Debug",
"--runtime",
"linux-x64"
],
"problemMatcher": "$msCompile"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.AST/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type SourceLocation =
static member Empty = SourceLocation.Create(start = Position.Empty, ``end`` = Position.Empty)

override x.ToString() =
sprintf $"(L%i{x.start.line},%i{x.start.column}-L%i{x.``end``.line},%i{x.``end``.column})"
$"(L%i{x.start.line},%i{x.start.column}-L%i{x.``end``.line},%i{x.``end``.column})"

type NumberKind =
| Int8
Expand Down
4 changes: 2 additions & 2 deletions src/Fable.Compiler/Globbing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Glob =
let serverName = splits.[2]
let share = splits.[3]

[ Directory(sprintf "\\\\%s\\%s" serverName share) ], splits |> Seq.skip 4
[ Directory($"\\\\%s{serverName}\\%s{share}") ], splits |> Seq.skip 4
elif splits.Length >= 2 && Path.IsPathRooted input && driveRegex.IsMatch splits.[0] then
[ Directory(splits.[0] + "\\") ], splits |> Seq.skip 1
elif splits.Length >= 2 && Path.IsPathRooted input && input.StartsWith '/' then
Expand Down Expand Up @@ -209,7 +209,7 @@ module Glob =
"wildcard", (@"\\\*", @"([^\\/]*)")
]
|> List.map (fun (key, (pattern, replace)) ->
let pattern = sprintf "(?<%s>%s)" key pattern
let pattern = $"(?<%s{key}>%s{pattern})"
key, (pattern, replace)
)

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Replacements.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ module AnonRecords =
| AlwaysAny = 0b0100

let private makeType = TypeHelpers.makeType Map.empty
let private quote = sprintf "'%s'"
let private quote s = $"'%s{s}'"
let private unreachable () = failwith "unreachable"
let private formatType = getTypeFullName true

Expand Down
8 changes: 4 additions & 4 deletions src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,10 @@ module Exprs =
let TODO_EXPR name : Expr =
mkStrLit ("TODO_EXPR_" + name) |> mkLitExpr

//for debugging purposes - decorate any expr with some metadata
let BLOCK_COMMENT_SUFFIX comment expr : Expr =
ExprKind.EmitExpression(sprintf "($0 /* %A */)" comment, mkVec [ expr ])
|> mkExpr
// //for debugging purposes - decorate any expr with some metadata
// let BLOCK_COMMENT_SUFFIX comment expr : Expr =
// ExprKind.EmitExpression($"($0 /* %A{comment} */)", mkVec [ expr ])
// |> mkExpr

[<AutoOpen>]
module Stmts =
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Rust/Fable2Rust.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,7 @@ module Util =
let rec transformExpr (com: IRustCompiler) ctx (fableExpr: Fable.Expr) : Rust.Expr =
match fableExpr with
| Fable.Unresolved(e, t, r) ->
"Unexpected unresolved expression: %A{e}" |> addError com [] r
$"Unexpected unresolved expression: %A{e}" |> addError com [] r
mkUnitExpr ()

| Fable.TypeCast(e, t) -> transformCast com ctx t e
Expand Down
8 changes: 4 additions & 4 deletions src/fable-compiler-js/src/ProjectParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ let getXmlWithoutComments xml =
Regex.Replace(xml, @"<!--[\s\S]*?-->", "")

let getXmlTagContents tag xml =
let pattern = sprintf @"<%s[^>]*>([^<]*)<\/%s[^>]*>" tag tag
let pattern = $"""<%s{tag}[^>]*>([^<]*)<\/%s{tag}[^>]*>"""
Regex.Matches(xml, pattern) |> Seq.map (fun m -> m.Groups[1].Value.Trim())

let getXmlTagContentsFirstOrDefault tag defaultValue xml =
defaultArg (getXmlTagContents tag xml |> Seq.tryHead) defaultValue

let getXmlTagAttributes1 tag attr1 xml =
let pattern = sprintf """<%s\s+[^>]*%s\s*=\s*("[^"]*|'[^']*)""" tag attr1
let pattern = $"""<%s{tag}\s+[^>]*%s{attr1}\s*=\s*("[^"]*|'[^']*)"""

Regex.Matches(xml, pattern)
|> Seq.map (fun m -> m.Groups[1].Value.TrimStart('"').TrimStart(''').Trim())

let getXmlTagAttributes2 tag attr1 attr2 xml =
let pattern =
sprintf """<%s\s+[^>]*%s\s*=\s*("[^"]*|'[^']*)[^>]*%s\s*=\s*("[^"]*|'[^']*)""" tag attr1 attr2
$"""<%s{tag}\s+[^>]*%s{attr1}\s*=\s*("[^"]*|'[^']*)[^>]*%s{attr2}\s*=\s*("[^"]*|'[^']*)"""

Regex.Matches(xml, pattern)
|> Seq.map (fun m ->
Expand Down Expand Up @@ -65,7 +65,7 @@ let parsePackageSpec nuspecPath =
let resolvePackage (pkgName, pkgVersion) =
if not (isSystemPackage pkgName) then
let homePath = getHomePath().Replace('\\', '/')
let nugetPath = sprintf ".nuget/packages/%s/%s" pkgName pkgVersion
let nugetPath = $".nuget/packages/%s{pkgName}/%s{pkgVersion}"
let pkgPath = Path.Combine(homePath, nugetPath.ToLowerInvariant())
let libPath = Path.Combine(pkgPath, "lib")
let fablePath = Path.Combine(pkgPath, "fable")
Expand Down
50 changes: 25 additions & 25 deletions src/fable-compiler-js/src/app.fs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ type SourceWriter(sourcePath, targetPath, projDir, options: CmdLineOptions, file
let printErrors showWarnings (errors: Fable.Standalone.Error[]) =
let printError (e: Fable.Standalone.Error) =
let errorType =
(if e.IsWarning then
"Warning"
else
"Error")
if e.IsWarning then
"Warning"
else
"Error"

printfn "%s" $"{e.FileName} ({e.StartLine},{e.StartColumn}): {errorType}: {e.Message}"
printfn $"%s{e.FileName} (%d{e.StartLine},%d{e.StartColumn}): %s{errorType}: %s{e.Message}"

let warnings, errors = errors |> Array.partition (fun e -> e.IsWarning)
let hasErrors = not (Array.isEmpty errors)
Expand All @@ -201,9 +201,9 @@ let runAsync computation =
async {
try
do! computation
with e ->
printfn "[ERROR] %s" e.Message
printfn "%s" e.StackTrace
with ex ->
printfn $"ERROR: %s{ex.Message}"
printfn $"%s{ex.StackTrace}"
}
|> Async.StartImmediate

Expand All @@ -229,29 +229,28 @@ let parseFiles projectFileName options =
let fable = initFable ()

let optimizeFlag =
"--optimize"
+ (if options.optimize then
"+"
else
"-")
if options.optimize then
"--optimize+"
else
"--optimize-"

let otherOptions = otherOptions |> Array.append [| optimizeFlag |]

let createChecker () =
fable.CreateChecker(references, readAllBytes, otherOptions)

let checker, ms0 = measureTime createChecker ()
printfn "fable-compiler-js v%s" (getVersion ())
printfn "--------------------------------------------"
printfn "InteractiveChecker created in %d ms" ms0
printfn $"fable-compiler-js v%s{getVersion ()}"
printfn $"--------------------------------------------"
printfn $"InteractiveChecker created in %d{ms0} ms"

// parse F# files to AST
let parseFSharpProject () =
fable.ParseAndCheckProject(checker, projectFileName, fileNames, sources)

let parseRes, ms1 = measureTime parseFSharpProject ()
printfn "Project: %s, FCS time: %d ms" projectFileName ms1
printfn "--------------------------------------------"
printfn $"Project: %s{projectFileName}, FCS time: %d{ms1} ms"
printfn $"--------------------------------------------"

// print warnings and errors
let showWarnings = not options.benchmark
Expand Down Expand Up @@ -290,7 +289,7 @@ let parseFiles projectFileName options =
| "dart" -> ".dart"
| "rs"
| "rust" -> ".rs"
| _ -> failwithf "Unsupported language: %s" options.language
| _ -> failwith $"Unsupported language: %s{options.language}"

let fileExt =
if Option.isNone options.outDir then
Expand All @@ -317,7 +316,7 @@ let parseFiles projectFileName options =

// transform F# AST to target language AST
let res, ms2 = measureTime parseFable (parseRes, fileName)
printfn "File: %s, Fable time: %d ms" fileName ms2
printfn $"File: %s{fileName}, Fable time: %d{ms2} ms"
res.FableErrors |> printErrors showWarnings

// get output path
Expand Down Expand Up @@ -392,7 +391,7 @@ let run opts projectFileName outDir =
Path.Combine(outDir, Path.GetFileNameWithoutExtension(projectFileName) + ".js")

let runArgs = opts[i + 1 ..] |> String.concat " "
sprintf "node %s %s" scriptFile runArgs
$"node %s{scriptFile} %s{runArgs}"
)

let options =
Expand Down Expand Up @@ -433,17 +432,18 @@ Options:
| Some i -> Array.splitAt i argv

match opts, args with
| _, _ when argv |> hasFlag "--help" -> printfn "%s" usage
| _, _ when argv |> hasFlag "--version" -> printfn "v%s" (getVersion ())
| _, _ when argv |> hasFlag "--help" -> printfn $"%s{usage}"
| _, _ when argv |> hasFlag "--version" -> printfn $"v%s{getVersion ()}"
| _, [| projectFileName |] -> run opts projectFileName None
| _, [| projectFileName; outDir |] -> run opts projectFileName (Some outDir)
| _ -> printfn "%s" usage
| _ -> printfn $"%s{usage}"

[<EntryPoint>]
let main argv =
try
parseArguments argv
with ex ->
printfn "Error: %s\n%s" ex.Message ex.StackTrace
printfn $"ERROR: %s{ex.Message}"
printfn $"%s{ex.StackTrace}"

0
6 changes: 1 addition & 5 deletions src/fable-library-ts/Seq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ module Enumerator =
let cast (e: IEnumerator<'T>) : IEnumerator<'T> =
let current () = unbox<'T> e.Current
let next () = e.MoveNext()

let dispose () =
match e with
| :? System.IDisposable as e -> e.Dispose()
| _ -> ()
let dispose () = e.Dispose()

fromFunctions current next dispose

Expand Down
36 changes: 18 additions & 18 deletions src/fable-standalone/test/bench-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
"scripts": {
"clean": "git clean -fdX",

"build-tests-rust": "npm run fable -- ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib --lang Rust",
"build-tests-dart": "npm run fable -- ../../../../tests/Dart/src/Fable.Tests.Dart.fsproj --outDir ./out-tests-dart --fableLib ./out-lib --lang Dart",
"build-tests-python": "npm run fable -- ../../../../tests/Python/Fable.Tests.Python.fsproj --outDir ./out-tests-python --fableLib ./out-lib --lang Python",
"build-tests-rust-node": "npm run fable-node -- ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib --lang Rust",
"build-tests-dart-node": "npm run fable-node -- ../../../../tests/Dart/src/Fable.Tests.Dart.fsproj --outDir ./out-tests-dart --fableLib ./out-lib --lang Dart",
"build-tests-python-node": "npm run fable-node -- ../../../../tests/Python/Fable.Tests.Python.fsproj --outDir ./out-tests-python --fableLib ./out-lib --lang Python",

"prebuild-lib-ts": "mkdir -p out-lib-ts && cp -r ../../../fable-library-ts/*.ts out-lib-ts && cp -r ../../../fable-library-ts/lib out-lib-ts",
"build-lib-ts": "npm run $FABLE -- ../../../fable-library-ts/Fable.Library.TypeScript.fsproj --outDir ./out-lib-ts --fableLib ./out-lib-ts --lang TypeScript --exclude Fable.Core",
"postbuild-lib-ts": "cp src/tsconfig.json out-lib-ts && npm run tsc -- -p ./out-lib-ts --outDir ./out-lib-js",
Expand All @@ -36,7 +29,7 @@
"benchmark-node": "npm run fable-node -- src/bench-compiler.fsproj --outDir ./out-node2 --benchmark",
"benchmark-bundle": "npm run fable-bundle -- src/bench-compiler.fsproj --outDir ./out-node2 --benchmark",

"publish-native": "cd src && dotnet publish -c Release -r linux-x64",
"publish-native": "cd src && dotnet publish -c Release -r linux-x64 & echo \u001B[35m Needs PublishAot enabled in project!",
"prefable-native": "npm run publish-native",
"fable-native": "src/bin/Release/net8.0/linux-x64/native/bench-compiler",
"prebuild-native-js": "FABLE=fable-native npm run build-lib-ts",
Expand All @@ -54,24 +47,31 @@
"terser-bundle": "npm run terser -- dist/bundle.js -o dist/bundle.min.js --mangle --compress",
"webpack-bundle": "npm run webpack -- -p --entry ./out-node/app.js --output ./dist/bundle.min.js --target node",

"prebuild-test-js": "npm run clean && npm run build-lib-ts",
"prebuild-test-ts": "npm run clean && npm run build-lib-ts",
"prebuild-test-js": "npm run clean && FABLE=fable npm run build-lib-ts",
"prebuild-test-ts": "npm run clean && FABLE=fable npm run build-lib-ts",
"build-test-js": "npm run fable -- ../../../../../fable-test/fable-test.fsproj --outDir ./out-test --fableLib ./out-lib-js --sourceMaps",
"build-test-ast": "npm run fable -- ../../../../../fable-test/fable-test.fsproj --outDir ./out-test --fableLib ./out-lib-js --printAst",
"build-test-ts": "npm run fable -- ../../../../../fable-test/fable-test.fsproj --outDir ./out-test-ts --fableLib ./out-lib-ts --lang TypeScript",
"build-test-opt": "npm run build-test-js -- --optimize",
"build-test-node": "npm run fable-node -- ../../../../../fable-test/fable-test.fsproj --outDir ./out-test --fableLib ./out-lib --sourceMaps",
"build-test-node-js": "npm run fable-node -- ../../../../../fable-test/fable-test.fsproj --outDir ./out-test --fableLib ./out-lib-js --sourceMaps",
"build-test-node-ts": "npm run build-test-node --lang TypeScript",
"postbuild-test-js": "node ./out-test/src/main.js",
"postbuild-test-ts": "cp src/tsconfig.json out-test-ts && npm run tsc -- -p out-test-ts --outDir ./out-test-js",
"test": "node ./out-test/src/test.js",

"prebuild-tests-js": "npm run clean && npm run build-lib-ts",
"prebuild-tests-ts": "npm run clean && npm run build-lib-ts",
"build-tests-js": "npm run fable -- ../../../../tests/Js/Main/Fable.Tests.fsproj --outDir ./out-tests --fableLib ./out-lib --sourceMaps",
"prebuild-tests-js": "npm run clean && FABLE=fable npm run build-lib-ts",
"prebuild-tests-ts": "npm run clean && FABLE=fable npm run build-lib-ts",
"build-tests-js": "npm run fable -- ../../../../tests/Js/Main/Fable.Tests.fsproj --outDir ./out-tests --fableLib ./out-lib-js --sourceMaps",
"build-tests-ts": "npm run build-tests-js -- --fableLib ./out-lib-ts --lang TypeScript",
"build-tests-opt": "npm run build-tests-js -- --optimize",
"build-tests-node": "npm run fable-node -- ../../../../tests/Js/Main/Fable.Tests.fsproj --outDir ./out-tests --fableLib ./out-lib --sourceMaps",
"tests": "npm run mocha -- out-tests --colors --reporter dot",
"build-tests-node": "npm run fable-node -- ../../../../tests/Js/Main/Fable.Tests.fsproj --outDir ./out-tests --fableLib ./out-lib-js --sourceMaps",
"postbuild-tests-js": "npm run mocha -- out-tests --colors --reporter dot -t 10000",

"build-tests-rust": "npm run fable -- ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib-rust --lang Rust",
"build-tests-dart": "npm run fable -- ../../../../tests/Dart/src/Fable.Tests.Dart.fsproj --outDir ./out-tests-dart --fableLib ./out-lib-dart --lang Dart",
"build-tests-python": "npm run fable -- ../../../../tests/Python/Fable.Tests.Python.fsproj --outDir ./out-tests-python --fableLib ./out-lib-python --lang Python",
"build-tests-rust-node": "npm run fable-node -- ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib-rust --lang Rust",
"build-tests-dart-node": "npm run fable-node -- ../../../../tests/Dart/src/Fable.Tests.Dart.fsproj --outDir ./out-tests-dart --fableLib ./out-lib-dart --lang Dart",
"build-tests-python-node": "npm run fable-node -- ../../../../tests/Python/Fable.Tests.Python.fsproj --outDir ./out-tests-python --fableLib ./out-lib-python --lang Python",

"tsc-lib-init": "npm run tsc -- --init --target es2020 --module es2020 --allowJs",

Expand All @@ -96,7 +96,7 @@
"speedscope": "speedscope profile.v8log.json",
"flamegraph": "perf script | ../../../../../FlameGraph/stackcollapse-perf.pl | ../../../../../FlameGraph/flamegraph.pl > perf.svg",
"trace-node": "node --trace-deopt out-node/app.js src/bench-compiler.fsproj --outDir ./out-node2 > deopt.log",
"trace-rust": "dotnet trace collect --duration 00:00:01:00 --format speedscope -- dotnet src/bin/Release/net8.0/bench-compiler.dll ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib --lang Rust",
"trace-rust": "dotnet trace collect --duration 00:00:01:00 --format speedscope -- dotnet src/bin/Release/net8.0/bench-compiler.dll ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib-rust --lang Rust",
"heaptrack-native": "heaptrack ./src/bin/Release/net8.0/linux-x64/native/bench-compiler src/bench-compiler.fsproj --outDir ./out-node2 --benchmark",
"heaptrack-print": "heaptrack_print heaptrack.*.gz -F heap_alloc.log",
"heaptrack-flamegraph": "../../../../../FlameGraph/flamegraph.pl --title \"heaptrack: allocations\" --colors mem --countname allocations < heap_alloc.log > heap_alloc.svg",
Expand Down
Loading
Loading