Blame


1 b85a3496 2023-04-14 thomas #!/bin/sh
2 b85a3496 2023-04-14 thomas #
3 b85a3496 2023-04-14 thomas # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 b85a3496 2023-04-14 thomas # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
5 b85a3496 2023-04-14 thomas #
6 b85a3496 2023-04-14 thomas # Permission to use, copy, modify, and distribute this software for any
7 b85a3496 2023-04-14 thomas # purpose with or without fee is hereby granted, provided that the above
8 b85a3496 2023-04-14 thomas # copyright notice and this permission notice appear in all copies.
9 b85a3496 2023-04-14 thomas #
10 b85a3496 2023-04-14 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 b85a3496 2023-04-14 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 b85a3496 2023-04-14 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 b85a3496 2023-04-14 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 b85a3496 2023-04-14 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 b85a3496 2023-04-14 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 b85a3496 2023-04-14 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 b85a3496 2023-04-14 thomas
18 b85a3496 2023-04-14 thomas . ../cmdline/common.sh
19 b85a3496 2023-04-14 thomas
20 13bc6832 2023-04-22 thomas unset TOG_COLORS
21 13bc6832 2023-04-22 thomas unset TOG_DIFF_ALGORITHM
22 b85a3496 2023-04-14 thomas unset TOG_VIEW_SPLIT_MODE
23 b85a3496 2023-04-14 thomas unset LC_ALL
24 13bc6832 2023-04-22 thomas export TERM=vt220
25 b85a3496 2023-04-14 thomas export LC_ALL=C.UTF-8
26 b85a3496 2023-04-14 thomas export COLUMNS=80
27 b85a3496 2023-04-14 thomas export LINES=24
28 b85a3496 2023-04-14 thomas
29 b85a3496 2023-04-14 thomas widechar_filename()
30 b85a3496 2023-04-14 thomas {
31 b85a3496 2023-04-14 thomas echo "選り抜き記事"
32 b85a3496 2023-04-14 thomas }
33 b85a3496 2023-04-14 thomas
34 b85a3496 2023-04-14 thomas widechar_file_content()
35 b85a3496 2023-04-14 thomas {
36 b85a3496 2023-04-14 thomas cat <<-EOF
37 b85a3496 2023-04-14 thomas ウィリアム・ユワート・グラッドストン(英語: William Ewart Gladstone PC FRS FSS、1809年12月29日 - 1898年5月19日)は、イギリスの政治家。
38 b85a3496 2023-04-14 thomas
39 b85a3496 2023-04-14 thomas ヴィクトリア朝中期から後期にかけて、自由党を指導して、4度にわたり首相を務めた。
40 b85a3496 2023-04-14 thomas
41 b85a3496 2023-04-14 thomas 生涯を通じて敬虔なイングランド国教会の信徒であり、キリスト教の精神を政治に反映させることを目指した。多くの自由主義改革を行い、帝国主義にも批判的であった。好敵手である保守党党首ベンジャミン・ディズレーリとともにヴィクトリア朝イギリスの政党政治を代表する人物として知れる。……
42 b85a3496 2023-04-14 thomas EOF
43 b85a3496 2023-04-14 thomas }
44 b85a3496 2023-04-14 thomas
45 b85a3496 2023-04-14 thomas widechar_logmsg()
46 b85a3496 2023-04-14 thomas {
47 b85a3496 2023-04-14 thomas cat <<-EOF
48 b85a3496 2023-04-14 thomas 選り抜き記事ウィリアム・ユワート・グラッドストン(英語: William Ewart Gladstone PC FRS FSS、1809年12月29日 - 1898年5月19日)は、イギリスの政治家。
49 b85a3496 2023-04-14 thomas
50 b85a3496 2023-04-14 thomas
51 b85a3496 2023-04-14 thomas 良質な記事 おまかせ表示 つまみ読み 選考
52 b85a3496 2023-04-14 thomas EOF
53 b85a3496 2023-04-14 thomas }
54 b85a3496 2023-04-14 thomas
55 b85a3496 2023-04-14 thomas widechar_commit()
56 b85a3496 2023-04-14 thomas {
57 b85a3496 2023-04-14 thomas local repo="$1"
58 b85a3496 2023-04-14 thomas
59 b85a3496 2023-04-14 thomas echo "$(widechar_file_content)" > $repo/$(widechar_filename)
60 b85a3496 2023-04-14 thomas
61 b85a3496 2023-04-14 thomas (cd $repo && git add $(widechar_filename) > /dev/null)
62 b85a3496 2023-04-14 thomas (cd $repo && git commit -q --cleanup=verbatim -m "$(widechar_logmsg)" \
63 b85a3496 2023-04-14 thomas > /dev/null)
64 b85a3496 2023-04-14 thomas }
65 b85a3496 2023-04-14 thomas
66 b85a3496 2023-04-14 thomas set_test_env()
67 b85a3496 2023-04-14 thomas {
68 fa9bb690 2023-04-22 thomas export TOG_TEST_SCRIPT=$1
69 b85a3496 2023-04-14 thomas export TOG_SCR_DUMP=$2
70 b85a3496 2023-04-14 thomas
71 b85a3496 2023-04-14 thomas if [ -n "${3}" ]; then
72 b85a3496 2023-04-14 thomas export COLUMNS=${3}
73 b85a3496 2023-04-14 thomas fi
74 b85a3496 2023-04-14 thomas
75 b85a3496 2023-04-14 thomas if [ -n "${4}" ]; then
76 b85a3496 2023-04-14 thomas export LINES=${4}
77 b85a3496 2023-04-14 thomas fi
78 b85a3496 2023-04-14 thomas }
79 b85a3496 2023-04-14 thomas
80 b85a3496 2023-04-14 thomas test_init()
81 b85a3496 2023-04-14 thomas {
82 b85a3496 2023-04-14 thomas local testname="$1"
83 b85a3496 2023-04-14 thomas local columns="$2"
84 b85a3496 2023-04-14 thomas local lines="$3"
85 b85a3496 2023-04-14 thomas local no_tree="$4"
86 b85a3496 2023-04-14 thomas
87 b85a3496 2023-04-14 thomas if [ -z "$testname" ]; then
88 b85a3496 2023-04-14 thomas echo "No test name provided" >&2
89 b85a3496 2023-04-14 thomas return 1
90 b85a3496 2023-04-14 thomas fi
91 b85a3496 2023-04-14 thomas
92 d6e78555 2023-06-01 thomas testroot=`mktemp -d "$GOT_TEST_ROOT/tog-test-$testname-XXXXXXXXXX"`
93 b85a3496 2023-04-14 thomas
94 c5f4d357 2023-04-22 thomas set_test_env $testroot/$testname $testroot/view $columns $lines
95 b85a3496 2023-04-14 thomas
96 b85a3496 2023-04-14 thomas mkdir $testroot/repo
97 b85a3496 2023-04-14 thomas git_init $testroot/repo
98 b85a3496 2023-04-14 thomas
99 b85a3496 2023-04-14 thomas if [ -z "$no_tree" ]; then
100 b85a3496 2023-04-14 thomas make_test_tree $testroot/repo
101 b85a3496 2023-04-14 thomas cd $testroot/repo && git add .
102 b85a3496 2023-04-14 thomas git_commit $testroot/repo -m "adding the test tree"
103 b85a3496 2023-04-14 thomas fi
104 b85a3496 2023-04-14 thomas }
105 b85a3496 2023-04-14 thomas
106 b85a3496 2023-04-14 thomas run_test()
107 b85a3496 2023-04-14 thomas {
108 b85a3496 2023-04-14 thomas testfunc="$1"
109 b85a3496 2023-04-14 thomas
110 b85a3496 2023-04-14 thomas if [ -n "$regress_run_only" ]; then
111 b85a3496 2023-04-14 thomas case "$regress_run_only" in
112 b85a3496 2023-04-14 thomas *$testfunc*) ;;
113 b85a3496 2023-04-14 thomas *) return ;;
114 b85a3496 2023-04-14 thomas esac
115 b85a3496 2023-04-14 thomas fi
116 b85a3496 2023-04-14 thomas
117 b85a3496 2023-04-14 thomas if [ -z "$GOT_TEST_QUIET" ]; then
118 b85a3496 2023-04-14 thomas echo -n "$testfunc "
119 b85a3496 2023-04-14 thomas fi
120 b85a3496 2023-04-14 thomas
121 b85a3496 2023-04-14 thomas # run test in subshell to keep defaults unchanged
122 b85a3496 2023-04-14 thomas ($testfunc)
123 b85a3496 2023-04-14 thomas }