summaryrefslogtreecommitdiffstats
path: root/ci/script.sh
blob: c0227c564601aad1d1b0cc3b6f881309733b90b0 (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
#!/bin/bash

# build, test and generate docs in this phase

set -ex

. "$(dirname $0)/utils.sh"

main() {
    # Travis sometimes caches the target directory, which makes testing the
    # output of cargo a little trickier. So just wipe it.
    cargo clean
    # Test a normal debug build.
    cargo build --target "$TARGET" --verbose --all

    # Show the output of the most recent build.rs stderr.
    set +x
    stderr="$(find "target/$TARGET/debug" -name stderr -print0 | xargs -0 ls -t | head -n1)"
    if [ -s "$stderr" ]; then
      echo "===== $stderr ====="
      cat "$stderr"
      echo "====="
    fi
    set -x

    # sanity check the file type
    file target/"$TARGET"/debug/rg

    # Apparently tests don't work on arm, so just bail now. I guess we provide
    # ARM releases on a best effort basis?
    if is_arm; then
      return 0
    fi

    # Test that zsh completions are in sync with ripgrep's actual args.
    "$(dirname "${0}")/test_complete.sh"

    # Check that we've generated man page and other shell completions.
    outdir="$(cargo_out_dir "target/$TARGET/debug")"
    file "$outdir/rg.bash"
    file "$outdir/rg.fish"
    file "$outdir/_rg.ps1"
    # N.B. man page isn't generated on ARM cross-compile, but we gave up
    # long before this anyway.
    file "$outdir/rg.1"

    # Run tests for ripgrep and all sub-crates.
    cargo test --target "$TARGET" --verbose --all
}

main