コード例 #1
0
ファイル: check_tidy.py プロジェクト: shanghaife/iotjs
def check_tidy(src_dir, options=None):
    allowed_exts = ['.c', '.h', '.js', '.py', '.sh', '.cmake']
    allowed_files = ['CMakeLists.txt']
    clang_format_exts = ['.c', '.h']
    skip_dirs = [
        'deps', 'build', '.git', 'node_modules', 'coverage', 'iotjs_modules',
        'IoTjsApp'
    ]
    skip_files = [
        'check_signed_off.sh', '__init__.py', 'iotjs_js.c', 'iotjs_js.h',
        'iotjs_string_ext.inl.h', "iotjs_module_inl.h", 'ble.js',
        'ble_hci_socket_acl_stream.js', 'ble_hci_socket_smp.js',
        'ble_hci_socket_hci.js', 'ble_hci_socket_gap.js',
        'ble_hci_socket_gatt.js', 'ble_hci_socket_mgmt.js',
        'ble_hci_socket_bindings.js', 'ble_characteristic.js',
        'test_ble_setservices.js', '.eslintrc.js', 'c_source_templates.py',
        'cpp_source_templates.py'
    ]

    style = StyleChecker()
    style.set_rules()
    clang = ClangFormat(clang_format_exts, skip_files, options)
    eslint = EslintChecker(options)

    file_filter = FileFilter(allowed_exts, allowed_files, skip_files)
    files = fs.files_under(src_dir, skip_dirs, file_filter)

    clang.check(files)
    style.check(files)
    eslint.check()

    if clang.error_count:
        print("Detected clang-format problems:")
        print("".join(clang.diffs))
        print()

    if style.error_count:
        print("Detected style problems:")
        print("\n".join(style.errors))
        print()

    if eslint.error_count:
        print("Detected eslint problems:")
        print("\n".join(eslint.errors))
        print()

    total_errors = style.error_count + clang.error_count + eslint.error_count
    print("* total lines of code: %d" % style.count_lines)
    print("* total non-blank lines of code: %d" % style.count_valid_lines)
    print("* style errors: %d" % style.error_count)
    print("* clang-format errors: %d" % clang.error_count)
    print("* eslint errors: %d" % eslint.error_count)

    msg_color = Terminal.red if total_errors > 0 else Terminal.green
    Terminal.pprint("* total errors: %d" % (total_errors), msg_color)
    print()

    if total_errors:
        ex.fail("Failed tidy check")
コード例 #2
0
ファイル: check_tidy.py プロジェクト: Samsung/iotjs
    def _check_eslint(self):
        self._node = spawn.find_executable('node')
        if not self._node:
            Terminal.pprint('No node found,', Terminal.red)
            return

        self._eslint = spawn.find_executable('node_modules/.bin/eslint')
        if not self._eslint:
            self._eslint = spawn.find_executable('eslint')
            if not self._eslint:
                Terminal.pprint('No eslint found.', Terminal.red)
コード例 #3
0
ファイル: check_tidy.py プロジェクト: shanghaife/iotjs
    def _check_eslint(self):
        self._node = spawn.find_executable('node')
        if not self._node:
            Terminal.pprint('No node found,', Terminal.red)
            return

        self._eslint = spawn.find_executable('node_modules/.bin/eslint')
        if not self._eslint:
            self._eslint = spawn.find_executable('eslint')
            if not self._eslint:
                Terminal.pprint('No eslint found.', Terminal.red)
コード例 #4
0
    def _check_clang_format(self, base):
        clang_format = spawn.find_executable(base)

        if not clang_format:
            clang_format = spawn.find_executable("clang-format")
            if clang_format:
                Terminal.pprint(
                    "Using %s instead of %s" % (clang_format, base),
                    Terminal.yellow)
            else:
                Terminal.pprint("No %s found, skipping checks!", Terminal.red)

        self._clang_format = clang_format
コード例 #5
0
ファイル: check_tidy.py プロジェクト: Samsung/iotjs
    def _check_clang_format(self, base):
        clang_format = spawn.find_executable(base)

        if not clang_format:
            clang_format = spawn.find_executable("clang-format")
            if clang_format:
                Terminal.pprint(
                    "Using %s instead of %s" % (clang_format, base),
                    Terminal.yellow)
            else:
                Terminal.pprint("No %s found, skipping checks!" % base,
                    Terminal.red)

        self._clang_format = clang_format
コード例 #6
0
ファイル: build.py プロジェクト: shanghaife/iotjs
        print_progress('Clear build directories')
        test_build_root = fs.join(path.TEST_ROOT,
                                  'dynamicmodule',
                                  'build',
                                  options.target_os)
        fs.rmtree(test_build_root)
        fs.rmtree(options.build_root)

    # Perform init-submodule.
    if not options.no_init_submodule:
        print_progress('Initialize submodule')
        init_submodule()

    build_iotjs(options)

    Terminal.pprint("\nIoT.js Build Succeeded!!\n", Terminal.green)

    # Run tests.
    if options.run_test:
        print_progress('Run tests')
        if options.buildlib:
            print("Skip unit tests - build target is library\n")
        elif (options.host_tuple == options.target_tuple or
              (options.host_tuple == 'x86_64-linux' and
               options.target_tuple == 'i686-linux') or
              (options.host_tuple == 'x86_64-linux' and
               options.target_tuple == 'x86_64-mock')):
             run_checktest(options)
        else:
            print("Skip unit tests - target-host pair is not allowed\n")
    else:
コード例 #7
0
ファイル: build.py プロジェクト: Samsung/iotjs
    if options.clean:
        print_progress('Clear build directories')
        test_build_root = fs.join(path.TEST_ROOT,
                                  'napi',
                                  'build')
        fs.rmtree(test_build_root)
        fs.rmtree(options.build_root)

    # Perform init-submodule.
    if not options.no_init_submodule:
        print_progress('Initialize submodule')
        init_submodule()

    build_iotjs(options)

    Terminal.pprint("\nIoT.js Build Succeeded!!\n", Terminal.green)

    # Run tests.
    if options.run_test:
        print_progress('Run tests')
        if options.buildlib:
            print("Skip unit tests - build target is library\n")
        elif (options.host_tuple == options.target_tuple or
              (options.host_tuple == 'x86_64-linux' and
               options.target_tuple == 'i686-linux') or
              (options.host_tuple == 'x86_64-linux' and
               options.target_tuple == 'x86_64-mock')):
             run_checktest(options)
        else:
            print("Skip unit tests - target-host pair is not allowed\n")
    else:
コード例 #8
0
ファイル: check_tidy.py プロジェクト: Samsung/iotjs
def check_tidy(src_dir, options=None):
    allowed_exts = ['.c', '.h', '.js', '.py', '.sh', '.cmake']
    allowed_files = ['CMakeLists.txt']
    clang_format_exts = ['.c', '.h']
    skip_dirs = ['deps', 'build', '.git', 'node_modules', 'coverage',
                 'iotjs_modules', 'IoTjsApp']
    skip_files = ['check_license.py', 'check_signed_off.sh', '__init__.py',
                  'iotjs_js.c', 'iotjs_js.h', 'iotjs_string_ext.inl.h',
                  "iotjs_module_inl.h",
                  'ble.js',
                  'ble_hci_socket_acl_stream.js',
                  'ble_hci_socket_smp.js',
                  'ble_hci_socket_hci.js',
                  'ble_hci_socket_gap.js',
                  'ble_hci_socket_gatt.js',
                  'ble_hci_socket_mgmt.js',
                  'ble_hci_socket_bindings.js',
                  'ble_characteristic.js',
                  'node_api.h',
                  'node_api_types.h',
                  'test_ble_setservices.js',
                  '.eslintrc.js',
                  'c_source_templates.py',
                  'cpp_source_templates.py'
                  ]

    style = StyleChecker()
    style.set_rules()
    clang = ClangFormat(clang_format_exts, skip_files, options)
    eslint = EslintChecker(options)

    file_filter = FileFilter(allowed_exts, allowed_files, skip_files)
    files = fs.files_under(src_dir, skip_dirs, file_filter)

    clang.check(files)
    style.check(files)
    eslint.check()

    if clang.error_count:
        print("Detected clang-format problems:")
        print("".join(clang.diffs))
        print()

    if style.error_count:
        print("Detected style problems:")
        print("\n".join(style.errors))
        print()

    if eslint.error_count:
        print("Detected eslint problems:")
        print("\n".join(eslint.errors))
        print()

    total_errors = style.error_count + clang.error_count + eslint.error_count
    print("* total lines of code: %d" % style.count_lines)
    print("* total non-blank lines of code: %d" % style.count_valid_lines)
    print("* style errors: %d" % style.error_count)
    print("* clang-format errors: %d" % clang.error_count)
    print("* eslint errors: %d" % eslint.error_count)

    msg_color = Terminal.red if total_errors > 0 else Terminal.green
    Terminal.pprint("* total errors: %d" % (total_errors), msg_color)
    print()

    if total_errors:
        ex.fail("Failed tidy check")