Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
Build: Add code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Alxandr committed Jun 1, 2017
1 parent 458e720 commit 33bf2cd
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ before_install:
- export PATH=$HOME/.yarn/bin:$PATH

script:
- ./build.sh
- ./build.sh

after_success: yarn run codecov
7 changes: 4 additions & 3 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ Target "TestInstall" (fun _ ->

Target "TestBuild" (fun _ ->
forAllTests "build"
runDotnet (IO.Path.GetDirectoryName <| Seq.head projects) <| sprintf "fable node-run %s" jsCompiler
Environment.SetEnvironmentVariable ("INSTRUMENT_CODE", "1", EnvironmentVariableTarget.Process)
// TODO: Specify free port
runDotnet (IO.Path.GetDirectoryName <| Seq.head projects) <| sprintf "fable node-run \"%s\"" jsCompiler
)

Target "Test" (fun _ ->
let avaArgs = "test"
runYarn rootDir avaArgs
runYarn rootDir "test"
)

// --------------------------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const fileGlob = (pattern, dir) => new Promise((resolve, reject) => {
});
});

const babelConfig = ({ isSrc = false, relSource } = {}) => ({
const babelConfig = ({ isSrc = false, relSource, filename } = {}) => ({
filename,
sourceMaps: true,
sourceFileName: relSource,
plugins: [
Expand Down Expand Up @@ -74,17 +75,18 @@ const main = async (argv) => {

if (error) throw new Error(error);
if (logs.error) {
const errorMsg = logs.error.join('\n');
throw new Error(errorMsg);
for (const error of logs.error) {
console.log(error);
}
}

// TODO: Log warnings maybe?

const fsCode = await fs.readFile(fsFile, 'utf-8');
try {
const transformed = babel.transformFromAst(data, fsCode, babelConfig({ isSrc, isTest }));

const relPath = path.relative(__dirname, fsFile);
const transformed = babel.transformFromAst(data, fsCode, babelConfig({ isSrc, isTest, filename: relPath }));

const outFile = path.join(outDir, replaceExt(relPath, '.js'));
const outFileDir = path.dirname(outFile);
await fs.mkdirp(outFileDir);
Expand Down
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
{
"name": "test",
"name": "fable-ava",
"private": true,
"devDependencies": {
"ava": "^0.19.1",
"babel-core": "^6.24.1",
"babel-plugin-import-rename": "^1.0.1",
"babel-plugin-istanbul": "^4.1.3",
"babel-preset-env": "^1.5.1",
"codecov": "^2.2.0",
"fable-utils": "^1.0.0",
"fs-extra": "^3.0.1",
"glob": "^7.1.2",
"mkdirp": "^0.5.1",
"nyc": "^10.3.2"
},
"scripts": {
"test": "nyc ava bin/js/test/**/*.js"
"test": "nyc ava bin/js/test/**/*.js",
"codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
},
"ava": {}
"ava": {},
"nyc": {
"instrument": false,
"sourceMap": false,
"exclude": [
"**/packages/**",
"**/test/**"
]
}
}
6 changes: 3 additions & 3 deletions src/Fable.Ava/bindings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ type ITestContext =

type TestImpl = ITestContext -> Promise<unit>

[<Import("default", from="ava")>]
//[<Import("default", from="ava")>]
module Test =
[<Emit("$0($1)")>]
[<Import("default", from="ava"); Emit("$0($1)")>]
let create' (impl: TestImpl): unit = jsNative

[<Emit("$0($1,$2)")>]
[<Import("default", from="ava"); Emit("$0($1,$2)")>]
let create (name: string) (impl: TestImpl): unit = jsNative

[<Emit("$0.serial($1)")>]
Expand Down
2 changes: 1 addition & 1 deletion test/Fable.Ava.Test/test.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ open Fable.Ava
spec {
do! Assert.isTrue true <?> "true is true"
do! Assert.isFalse false <?> "false is false"
do! Assert.isFalsy true <?> "true should not be falsy :P"
do! Assert.isTruthy true <?> "true should not be falsy :P"
} |> Test.create "test"
99 changes: 99 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"

argv@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab"

arr-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
Expand Down Expand Up @@ -897,6 +901,10 @@ capture-stack-trace@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d"

caseless@~0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"

caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
Expand Down Expand Up @@ -1010,6 +1018,14 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

codecov@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/codecov/-/codecov-2.2.0.tgz#2d06817ceb8891eca6368836d4fb6bf6cc04ffd1"
dependencies:
argv "0.0.2"
request "2.79.0"
urlgrey "0.4.4"

color-convert@^1.0.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
Expand All @@ -1026,6 +1042,12 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

commander@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
dependencies:
graceful-readlink ">= 1.0.0"

common-path-prefix@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-1.0.0.tgz#cd52f6f0712e0baab97d6f9732874f22f47752c0"
Expand Down Expand Up @@ -1420,6 +1442,16 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"

generate-function@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"

generate-object-property@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0"
dependencies:
is-property "^1.0.0"

get-caller-file@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"
Expand Down Expand Up @@ -1507,6 +1539,10 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

"graceful-readlink@>= 1.0.0":
version "1.0.1"
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"

handlebars@^4.0.3:
version "4.0.10"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f"
Expand All @@ -1521,6 +1557,15 @@ har-schema@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"

har-validator@~2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d"
dependencies:
chalk "^1.1.1"
commander "^2.9.0"
is-my-json-valid "^2.12.4"
pinkie-promise "^2.0.0"

har-validator@~4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a"
Expand Down Expand Up @@ -1725,6 +1770,15 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"

is-my-json-valid@^2.12.4:
version "2.16.0"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693"
dependencies:
generate-function "^2.0.0"
generate-object-property "^1.1.0"
jsonpointer "^4.0.0"
xtend "^4.0.0"

is-npm@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4"
Expand Down Expand Up @@ -1761,6 +1815,10 @@ is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"

is-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"

is-redirect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"
Expand Down Expand Up @@ -1972,6 +2030,10 @@ jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"

jsonpointer@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9"

jsprim@^1.2.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918"
Expand Down Expand Up @@ -2594,6 +2656,10 @@ punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"

qs@~6.3.0:
version "6.3.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c"

qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
Expand Down Expand Up @@ -2750,6 +2816,31 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"

request@2.79.0:
version "2.79.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
caseless "~0.11.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.1.1"
har-validator "~2.0.6"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
oauth-sign "~0.8.1"
qs "~6.3.0"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "~0.4.1"
uuid "^3.0.0"

request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
Expand Down Expand Up @@ -3104,6 +3195,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

tunnel-agent@~0.4.1:
version "0.4.3"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb"

tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
Expand Down Expand Up @@ -3170,6 +3265,10 @@ url-parse-lax@^1.0.0:
dependencies:
prepend-http "^1.0.1"

urlgrey@0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f"

util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit 33bf2cd

Please sign in to comment.