From 3d81489a2656214e93c6ea983e82c55b310cd28b Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Thu, 26 Aug 2021 23:24:51 +0200 Subject: [PATCH] move rust lint script (#8726) --- tests/lint/rust_format.sh | 35 +++++++++++++++++++++++++++++++++++ tests/scripts/task_lint.sh | 3 +++ tests/scripts/task_rust.sh | 3 --- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100755 tests/lint/rust_format.sh diff --git a/tests/lint/rust_format.sh b/tests/lint/rust_format.sh new file mode 100755 index 000000000000..10c8feec1fcf --- /dev/null +++ b/tests/lint/rust_format.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +TVM_HOME="$(git rev-parse --show-toplevel)" +RUST_DIR="$TVM_HOME/rust" + +if [[ "$1" == "-i" ]]; then + INPLACE_FORMAT=1 + shift 1 +else + INPLACE_FORMAT=0 +fi + +cd $RUST_DIR + +if [[ ${INPLACE_FORMAT} -eq 1 ]]; then + cargo fmt +else + cargo fmt -- --check +fi diff --git a/tests/scripts/task_lint.sh b/tests/scripts/task_lint.sh index 12b32709a392..2889c3a94f11 100755 --- a/tests/scripts/task_lint.sh +++ b/tests/scripts/task_lint.sh @@ -39,6 +39,9 @@ tests/lint/cpplint.sh echo "clang-format check..." tests/lint/clang_format.sh +echo "Rust check..." +tests/lint/rust_format.sh + echo "black check..." tests/lint/python_format.sh diff --git a/tests/scripts/task_rust.sh b/tests/scripts/task_rust.sh index 4b34b6cf8db4..5cc1dc0503f7 100755 --- a/tests/scripts/task_rust.sh +++ b/tests/scripts/task_rust.sh @@ -43,9 +43,6 @@ echo "Using TVM_CARGO_VERSION=$TVM_CARGO_VERSION" export TVM_BIND_THREADS=0 export OMP_NUM_THREADS=1 -cd $RUST_DIR -cargo fmt -- --check - # First we test tvm-sys the core Rust bindings. cd $RUST_DIR/tvm-sys # First we test w/o the bindings feature on.