summaryrefslogtreecommitdiffstats
path: root/config/check_js_opcode.py
blob: c42ea5ee63fa9fea74615fcf7dd32b8d1ee52374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# vim: set ts=8 sts=4 et sw=4 tw=99:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# ----------------------------------------------------------------------------
# This script checks bytecode documentation in js/src/vm/Opcodes.h
# ----------------------------------------------------------------------------

from __future__ import absolute_import
from __future__ import print_function

import os
import sys

scriptname = os.path.basename(__file__)
topsrcdir = os.path.dirname(os.path.dirname(__file__))


def log_pass(text):
    print("TEST-PASS | {} | {}".format(scriptname, text))


def log_fail(text):
    print("TEST-UNEXPECTED-FAIL | {} | {}".format(scriptname, text))


def check_opcode():
    sys.path.insert(0, os.path.join(topsrcdir, "js", "src", "vm"))
    import jsopcode

    try:
        jsopcode.get_opcodes(topsrcdir)
    except Exception as e:
        log_fail(e.args[0])
        return False

    log_pass("ok")
    return True


def main():
    if not check_opcode():
        sys.exit(1)

    sys.exit(0)


if __name__ == "__main__":
    main()