• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# !/usr/bin/env python3
2# coding=utf-8
3"""
4* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
5*
6* HDF is dual licensed: you can use it either under the terms of
7* the GPL, or the BSD license, at your option.
8* See the LICENSE file in the root of this repository for complete details.
9"""
10import os
11import sys
12
13def do_test():
14    if not os.path.isfile("@ohos.test.d.ts"):
15        return
16    if not os.path.exists("out"):
17        os.mkdir("out")
18    ret = os.popen("node ../../../src/gen/cmd_gen.js -f @ohos.test.d.ts -o ./out")
19    print(ret.read())
20
21    os.chdir("out")
22    ret = os.popen("npx node-gyp configure build")
23    os.chdir("..")
24
25    if "COPY Release" not in ret.read():
26        print("error compile failed")
27        return
28    else:
29        print("compile ok")
30
31    os.system("npx mocha test.js")
32
33
34if __name__ == "__main__":
35    work_path = os.path.split(sys.argv[0])[0]
36    os.chdir(work_path)
37
38    if len(sys.argv) >= 2:
39        for fn in sys.argv[1:]:
40            if os.path.isdir(fn):
41                os.chdir(fn)
42                do_test()
43                os.chdir("..")
44            else:
45                print("error",fn,"is not exist")
46    else:
47        for fn in os.listdir("."):
48            if os.path.isdir(fn):
49                os.chdir(fn)
50                do_test()
51                os.chdir("..")
52