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 b85a3496 2023-04-14 thomas unset TOG_VIEW_SPLIT_MODE
21 b85a3496 2023-04-14 thomas unset LC_ALL
22 b85a3496 2023-04-14 thomas export LC_ALL=C.UTF-8
23 b85a3496 2023-04-14 thomas export COLUMNS=80
24 b85a3496 2023-04-14 thomas export LINES=24
25 b85a3496 2023-04-14 thomas
26 b85a3496 2023-04-14 thomas widechar_filename()
27 b85a3496 2023-04-14 thomas {
28 b85a3496 2023-04-14 thomas echo "選り抜き記事"
29 b85a3496 2023-04-14 thomas }
30 b85a3496 2023-04-14 thomas
31 b85a3496 2023-04-14 thomas widechar_file_content()
32 b85a3496 2023-04-14 thomas {
33 b85a3496 2023-04-14 thomas cat <<-EOF
34 b85a3496 2023-04-14 thomas ウィリアム・ユワート・グラッドストン(英語: William Ewart Gladstone PC FRS FSS、1809年12月29日 - 1898年5月19日)は、イギリスの政治家。
35 b85a3496 2023-04-14 thomas
36 b85a3496 2023-04-14 thomas ヴィクトリア朝中期から後期にかけて、自由党を指導して、4度にわたり首相を務めた。
37 b85a3496 2023-04-14 thomas
38 b85a3496 2023-04-14 thomas 生涯を通じて敬虔なイングランド国教会の信徒であり、キリスト教の精神を政治に反映させることを目指した。多くの自由主義改革を行い、帝国主義にも批判的であった。好敵手である保守党党首ベンジャミン・ディズレーリとともにヴィクトリア朝イギリスの政党政治を代表する人物として知れる。……
39 b85a3496 2023-04-14 thomas EOF
40 b85a3496 2023-04-14 thomas }
41 b85a3496 2023-04-14 thomas
42 b85a3496 2023-04-14 thomas widechar_logmsg()
43 b85a3496 2023-04-14 thomas {
44 b85a3496 2023-04-14 thomas cat <<-EOF
45 b85a3496 2023-04-14 thomas 選り抜き記事ウィリアム・ユワート・グラッドストン(英語: William Ewart Gladstone PC FRS FSS、1809年12月29日 - 1898年5月19日)は、イギリスの政治家。
46 b85a3496 2023-04-14 thomas
47 b85a3496 2023-04-14 thomas
48 b85a3496 2023-04-14 thomas 良質な記事 おまかせ表示 つまみ読み 選考
49 b85a3496 2023-04-14 thomas EOF
50 b85a3496 2023-04-14 thomas }
51 b85a3496 2023-04-14 thomas
52 b85a3496 2023-04-14 thomas widechar_commit()
53 b85a3496 2023-04-14 thomas {
54 b85a3496 2023-04-14 thomas local repo="$1"
55 b85a3496 2023-04-14 thomas
56 b85a3496 2023-04-14 thomas echo "$(widechar_file_content)" > $repo/$(widechar_filename)
57 b85a3496 2023-04-14 thomas
58 b85a3496 2023-04-14 thomas (cd $repo && git add $(widechar_filename) > /dev/null)
59 b85a3496 2023-04-14 thomas (cd $repo && git commit -q --cleanup=verbatim -m "$(widechar_logmsg)" \
60 b85a3496 2023-04-14 thomas > /dev/null)
61 b85a3496 2023-04-14 thomas }
62 b85a3496 2023-04-14 thomas
63 b85a3496 2023-04-14 thomas set_test_env()
64 b85a3496 2023-04-14 thomas {
65 fa9bb690 2023-04-22 thomas export TOG_TEST_SCRIPT=$1
66 b85a3496 2023-04-14 thomas export TOG_SCR_DUMP=$2
67 b85a3496 2023-04-14 thomas
68 b85a3496 2023-04-14 thomas if [ -n "${3}" ]; then
69 b85a3496 2023-04-14 thomas export COLUMNS=${3}
70 b85a3496 2023-04-14 thomas fi
71 b85a3496 2023-04-14 thomas
72 b85a3496 2023-04-14 thomas if [ -n "${4}" ]; then
73 b85a3496 2023-04-14 thomas export LINES=${4}
74 b85a3496 2023-04-14 thomas fi
75 b85a3496 2023-04-14 thomas }
76 b85a3496 2023-04-14 thomas
77 b85a3496 2023-04-14 thomas test_init()
78 b85a3496 2023-04-14 thomas {
79 b85a3496 2023-04-14 thomas local testname="$1"
80 b85a3496 2023-04-14 thomas local columns="$2"
81 b85a3496 2023-04-14 thomas local lines="$3"
82 b85a3496 2023-04-14 thomas local no_tree="$4"
83 b85a3496 2023-04-14 thomas
84 b85a3496 2023-04-14 thomas if [ -z "$testname" ]; then
85 b85a3496 2023-04-14 thomas echo "No test name provided" >&2
86 b85a3496 2023-04-14 thomas return 1
87 b85a3496 2023-04-14 thomas fi
88 b85a3496 2023-04-14 thomas
89 b85a3496 2023-04-14 thomas testroot=`mktemp -d "$GOT_TEST_ROOT/tog-test-$testname-XXXXXXXX"`
90 b85a3496 2023-04-14 thomas
91 c5f4d357 2023-04-22 thomas set_test_env $testroot/$testname $testroot/view $columns $lines
92 b85a3496 2023-04-14 thomas
93 b85a3496 2023-04-14 thomas mkdir $testroot/repo
94 b85a3496 2023-04-14 thomas git_init $testroot/repo
95 b85a3496 2023-04-14 thomas
96 b85a3496 2023-04-14 thomas if [ -z "$no_tree" ]; then
97 b85a3496 2023-04-14 thomas make_test_tree $testroot/repo
98 b85a3496 2023-04-14 thomas cd $testroot/repo && git add .
99 b85a3496 2023-04-14 thomas git_commit $testroot/repo -m "adding the test tree"
100 b85a3496 2023-04-14 thomas fi
101 b85a3496 2023-04-14 thomas }
102 b85a3496 2023-04-14 thomas
103 b85a3496 2023-04-14 thomas run_test()
104 b85a3496 2023-04-14 thomas {
105 b85a3496 2023-04-14 thomas testfunc="$1"
106 b85a3496 2023-04-14 thomas
107 b85a3496 2023-04-14 thomas if [ -n "$regress_run_only" ]; then
108 b85a3496 2023-04-14 thomas case "$regress_run_only" in
109 b85a3496 2023-04-14 thomas *$testfunc*) ;;
110 b85a3496 2023-04-14 thomas *) return ;;
111 b85a3496 2023-04-14 thomas esac
112 b85a3496 2023-04-14 thomas fi
113 b85a3496 2023-04-14 thomas
114 b85a3496 2023-04-14 thomas if [ -z "$GOT_TEST_QUIET" ]; then
115 b85a3496 2023-04-14 thomas echo -n "$testfunc "
116 b85a3496 2023-04-14 thomas fi
117 b85a3496 2023-04-14 thomas
118 b85a3496 2023-04-14 thomas # run test in subshell to keep defaults unchanged
119 b85a3496 2023-04-14 thomas ($testfunc)
120 b85a3496 2023-04-14 thomas }