aboutsummaryrefslogtreecommitdiff
path: root/ci/script.sh
blob: 645db3aacd4f0c1fe922c64407fc5f8c6b8bd2ba (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
set -euxo pipefail

main() {
    local T=$TARGET

    if [ $T = x86_64-unknown-linux-gnu ]; then
        # compile-fail and compile-pass tests
        case $TRAVIS_RUST_VERSION in
            nightly*)
                # TODO how to run a subset of these tests when timer-queue is disabled?
                cargo test --features timer-queue --test compiletest --target $T
        esac

        cargo check --target $T
        if [ $TARGET != thumbv6m-none-eabi ]; then
            cargo check --features timer-queue --target $T
        fi

        if [ $TRAVIS_RUST_VERSION != nightly ]; then
            rm -f .cargo/config
            if [ $TARGET != thumbv6m-none-eabi ]; then
                cargo doc --features timer-queue
            else
                cargo doc
            fi
            ( cd book/en && mdbook build )
            ( cd book/ru && mdbook build )

            local td=$(mktemp -d)
            cp -r target/doc $td/api
            mkdir $td/book
            cp -r book/en/book $td/book/en
            cp -r book/ru/book $td/book/ru
            cp LICENSE-* $td/book/en
            cp LICENSE-* $td/book/ru

            linkchecker $td/book/en/
            linkchecker $td/book/ru/
            linkchecker $td/api/rtfm/
            linkchecker $td/api/cortex_m_rtfm_macros/
        fi

        return
    fi

    cargo check --target $T --examples
    if [ $TARGET != thumbv6m-none-eabi ]; then
        cargo check --features timer-queue --target $T --examples
    fi

    # run-pass tests
    case $T in
        thumbv6m-none-eabi | thumbv7m-none-eabi)
            local exs=(
                idle
                init
                interrupt

                resource
                lock
                late
                static

                task
                message
                capacity

                singleton

                types
                not-send
                not-sync

                generics
                ramfunc
            )

            for ex in ${exs[@]}; do
                if [ $ex = ramfunc ] && [ $T = thumbv6m-none-eabi ]; then
                    # LLD doesn't support this at the moment
                    continue
                fi

                if [ $ex != types ]; then
                    cargo run --example $ex --target $T | \
                        diff -u ci/expected/$ex.run -

                    cargo run --example $ex --target $T --release | \
                        diff -u ci/expected/$ex.run -
                fi

                if [ $TARGET != thumbv6m-none-eabi ]; then
                    cargo run --features timer-queue --example $ex --target $T | \
                        diff -u ci/expected/$ex.run -

                    cargo run --features timer-queue --example $ex --target $T --release | \
                        diff -u ci/expected/$ex.run -
                fi
            done
    esac
}

# fake Travis variables to be able to run this on a local machine
if [ -z ${TRAVIS_BRANCH-} ]; then
    TRAVIS_BRANCH=auto
fi

if [ -z ${TRAVIS_PULL_REQUEST-} ]; then
    TRAVIS_PULL_REQUEST=false
fi

if [ -z ${TRAVIS_RUST_VERSION-} ]; then
    case $(rustc -V) in
        *nightly*)
            TRAVIS_RUST_VERSION=nightly
            ;;
        *beta*)
            TRAVIS_RUST_VERSION=beta
            ;;
        *)
            TRAVIS_RUST_VERSION=stable
            ;;
    esac
fi

if [ -z ${TARGET-} ]; then
    TARGET=$(rustc -Vv | grep host | cut -d ' ' -f2)
fi

if [ $TRAVIS_BRANCH != master ] || [ $TRAVIS_PULL_REQUEST != false ]; then
    main
fi