-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_update_all_test.sh
executable file
·71 lines (54 loc) · 2.4 KB
/
change_update_all_test.sh
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
#!/usr/bin/env bash
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh
assertions_sh="$(rlocation "${assertions_sh_location}")" || \
(echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1)
source "${assertions_sh}"
create_scratch_dir_sh_location=rules_bazel_integration_test/tools/create_scratch_dir.sh
create_scratch_dir_sh="$(rlocation "${create_scratch_dir_sh_location}")" || \
(echo >&2 "Failed to locate ${create_scratch_dir_sh_location}" && exit 1)
# MARK - Process Flags
bazel="${BIT_BAZEL_BINARY:-}"
workspace_dir="${BIT_WORKSPACE_DIR:-}"
# Process args
while (("$#")); do
case "${1}" in
"--bazel")
bazel="${2}"
shift 2
;;
"--workspace")
workspace_path="${2}"
shift 2
;;
*)
shift 1
;;
esac
done
[[ -n "${bazel:-}" ]] || fail "Must specify the location of the Bazel binary."
[[ -n "${workspace_dir:-}" ]] || fail "Must specify the location of the workspace directory."
# MARK - Create Scratch Directory
scratch_dir="$("${create_scratch_dir_sh}" --workspace "${workspace_dir}")"
cd "${scratch_dir}"
# MARK - Test Change, Test, and Update All
# Should not fail, no changes
"${bazel}" test //... || fail "Expected test to succeed as nothing has changed yet."
# Modify the file
# The spaces at the front of the statement should be removed by the formatter.
echo " let bar = 2" >> main.swift
# Should fail due to unformatted
"${bazel}" test //... && fail "Expected test to fail due to unformatted files."
# Format the Swift files and copy them back to the workspace
"${bazel}" run //:update_all || fail "Expected update_all to succeed."
# This should succeed now that the formatted files have been updated
"${bazel}" test //... || fail "Expected test to succeed after update_all."