Skip to content

Commit 44b02f7

Browse files
author
Hongbo Zhang
committed
bug fix for mocha detection
1 parent 5c94c82 commit 44b02f7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

jscomp/test/fs_test.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ let () =
4848

4949

5050
let () =
51+
(* Js.log ("ARGV", Bs_node.Process.process##argv); *)
5152
Mt.from_pair_suites __FILE__ !suites
53+

jscomp/test/mt.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
'use strict';
22

33
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions");
4-
var Process = require("process");
54
var Assert = require("assert");
65
var Curry = require("../../lib/js/curry");
7-
var Path = require("path");
86
var $$Array = require("../../lib/js/array");
7+
var Path = require("path");
98
var List = require("../../lib/js/list");
9+
var Process = require("process");
1010

1111
function is_mocha() {
1212
var match = $$Array.to_list(Process.argv);
1313
if (match) {
14-
var exec = Path.basename(match[0]);
15-
if (exec === "mocha") {
16-
return /* true */1;
14+
var match$1 = match[1];
15+
if (match$1) {
16+
var exec = Path.basename(match$1[0]);
17+
if (exec === "mocha") {
18+
return /* true */1;
19+
}
20+
else {
21+
return +(exec === "_mocha");
22+
}
1723
}
1824
else {
19-
return +(exec === "_mocha");
25+
return /* false */0;
2026
}
2127
}
2228
else {
@@ -92,4 +98,4 @@ function from_pair_suites(name, suites) {
9298

9399
exports.from_suites = from_suites;
94100
exports.from_pair_suites = from_pair_suites;
95-
/* process Not a pure module */
101+
/* assert Not a pure module */

jscomp/test/mt.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ let assert_notequal = neq
2828

2929
let is_mocha () =
3030
match Array.to_list Bs_node.Process.process##argv with
31-
| cmd :: _ ->
32-
let exec = Bs_node.Path.basename cmd in
31+
| _node :: mocha :: _ ->
32+
let exec = Bs_node.Path.basename mocha in
3333
exec = "mocha" || exec = "_mocha"
3434
| _ -> false
3535
(* assert -- raises an AssertionError which mocha handls better

0 commit comments

Comments
 (0)