Debian Codegraph @

tests/f/cylc-install/05-check-logs-git.t

raw
1 #!/usr/bin/env bash
2 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
3 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 #------------------------------------------------------------------------------
19 # Test that we only log version control info on workflow source dir
20 # when it is a subdir of a repo.
21
22 . "$(dirname "$0")/test_header"
23
24 if ! command -v 'git' > /dev/null; then
25 skip_all 'git not installed'
26 fi
27 # set_test_number 6
28 set_test_number 3
29
30 WORKFLOW="$(date | md5sum | awk '{print $1}')"
31 WORKFLOW_NAME="$(workflow_id "${TEST_NAME_BASE}")"
32 WORKFLOW_RUN_DIR="${RUN_DIR}/${WORKFLOW_NAME}/runN"
33
34 # Create a workflow in a subdirectory of the test tmpdir
35 mkdir "${WORKFLOW}"
36 cat > "${WORKFLOW}/flow.cylc" <<__HEREDOC__
37 [scheduler]
38 implicit tasks allowed = True
39 [scheduling]
40 initial cycle point = 1649
41 [[graph]]
42 R1 = foo
43 __HEREDOC__
44
45 # Touch some non-functional files
46 touch "${WORKFLOW}/test_file_in_workflow"
47 touch test_file_outside_workflow
48
49 # Initialize PWD as a git repo
50 git init .
51 git add .
52 git commit -m "commit 0"
53
54 # Make changes since commit:
55 echo "Inside workflow" > "${WORKFLOW}/test_file_in_workflow"
56 echo "Outside workflow" > test_file_outside_workflow
57
58 # Carry out actual test with relpath:
59 run_ok "${TEST_NAME_BASE}-install" \
60 cylc install "./${WORKFLOW}" --workflow-name "${WORKFLOW_NAME}"
61 DIFF_FILE="${WORKFLOW_RUN_DIR}/log/version/uncommitted.diff"
62 grep_ok "Inside workflow" "$DIFF_FILE"
63 grep_fail "Outside workflow" "$DIFF_FILE"
64
65 purge