xref: /rust-libc-0.2.174/ci/style.sh (revision 5d72cb1b)
1#!/bin/sh
2
3set -ex
4
5rustc ci/style.rs && ./style src
6
7rustup toolchain install nightly -c rustfmt --allow-downgrade
8rustup override set nightly
9command -v rustfmt
10rustfmt -V
11cargo fmt --all -- --check
12
13if shellcheck --version ; then
14    find . -name '*.sh' -print0 | xargs -0 shellcheck
15else
16    echo "shellcheck not found"
17    exit 1
18fi
19
20# Ensure that `sort` output is not locale-dependent
21export LC_ALL=C
22
23for file in libc-test/semver/*.txt; do
24    case "$file" in
25      *TODO*) continue ;;
26    esac
27
28    if ! sort -C "$file"; then
29        echo "Unsorted semver file $file"
30        exit 1
31    fi
32
33    duplicates=$(uniq -d "$file")
34    if [ -n "$duplicates" ]; then
35        echo "Semver file $file contains duplicates:"
36        echo "$duplicates"
37
38        exit 1
39    fi
40done
41