tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

check_js_opcode.py (1120B)


      1 # vim: set ts=8 sts=4 et sw=4 tw=99:
      2 # This Source Code Form is subject to the terms of the Mozilla Public
      3 # License, v. 2.0. If a copy of the MPL was not distributed with this
      4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      5 
      6 # ----------------------------------------------------------------------------
      7 # This script checks bytecode documentation in js/src/vm/Opcodes.h
      8 # ----------------------------------------------------------------------------
      9 
     10 import os
     11 import sys
     12 
     13 scriptname = os.path.basename(__file__)
     14 topsrcdir = os.path.dirname(os.path.dirname(__file__))
     15 
     16 
     17 def log_pass(text):
     18    print(f"TEST-PASS | {scriptname} | {text}")
     19 
     20 
     21 def log_fail(text):
     22    print(f"TEST-UNEXPECTED-FAIL | {scriptname} | {text}")
     23 
     24 
     25 def check_opcode():
     26    sys.path.insert(0, os.path.join(topsrcdir, "js", "src", "vm"))
     27    import jsopcode
     28 
     29    try:
     30        jsopcode.get_opcodes(topsrcdir)
     31    except Exception as e:
     32        log_fail(e.args[0])
     33        return False
     34 
     35    log_pass("ok")
     36    return True
     37 
     38 
     39 def main():
     40    if not check_opcode():
     41        sys.exit(1)
     42 
     43    sys.exit(0)
     44 
     45 
     46 if __name__ == "__main__":
     47    main()