11_js_filetype = FileType ([".js" ])
2+
23_modules_filetype = FileType (["node_modules" ])
34
45BASH_TEMPLATE = """
@@ -16,18 +17,6 @@ export NODE_PATH={node_paths}
1617"{node}" "{mocha}" {mocha_args} "{script_path}" $@
1718"""
1819
19-
20- def _get_abs_sourcepath (file ):
21- filename = str (file )
22- #print("filename: %s" % filename)
23- parts = filename .partition ("[source]]" )
24- prefix = parts [0 ][len ("Artifact:[" ):]
25- suffix = parts [2 ]
26- d = "/" .join ([prefix , suffix ])
27- #print("abs filename: %s" % d)
28- return d
29-
30-
3120def _get_node_modules_dir_from_binfile (file ):
3221 bin = str (file )
3322 parts = bin .partition ("[source]]" )
@@ -36,7 +25,6 @@ def _get_node_modules_dir_from_binfile(file):
3625 #print("prefix: %s, suffix_parts: %s" % (prefix, suffix_parts))
3726 return "/" .join ([prefix ] + suffix_parts [0 :2 ] + ["node_modules" ])
3827
39-
4028def _get_node_modules_dir_from_package_json (file ):
4129 filename = str (file )
4230 parts = filename .split ("]" )
@@ -46,8 +34,6 @@ def _get_node_modules_dir_from_package_json(file):
4634 d = "/" .join ([prefix , middle ] + suffix [0 :- 3 ] + ["node_modules" ])
4735 return d
4836
49-
50-
5137def mocha_test_impl (ctx ):
5238 inputs = []
5339 srcs = []
@@ -57,8 +43,6 @@ def mocha_test_impl(ctx):
5743 node_paths = []
5844 node_paths .append (_get_node_modules_dir_from_binfile (mocha ))
5945
60- mocha_path = _get_abs_sourcepath (mocha )
61-
6246 for file in ctx .files .modules :
6347 #print("file: %s" % file)
6448 if not file .basename .endswith ("node_modules" ):
@@ -84,14 +68,14 @@ def mocha_test_impl(ctx):
8468 node = node .short_path ,
8569 node_bin_path = node .dirname ,
8670 script_path = script .short_path ,
87- mocha = mocha_path ,
71+ mocha = mocha . path ,
8872 mocha_args = " " .join (ctx .attr .mocha_args ),
8973 ),
9074 )
9175
9276 #print("node_paths %s" % "\n".join(node_paths))
9377
94- runfiles = [node , script ] + inputs + srcs
78+ runfiles = [node , script , mocha ] + inputs + srcs
9579
9680 return struct (
9781 runfiles = ctx .runfiles (
@@ -100,7 +84,6 @@ def mocha_test_impl(ctx):
10084 ),
10185 )
10286
103-
10487mocha_test = rule (
10588 mocha_test_impl ,
10689 attrs = {
0 commit comments