Skip to content

Commit 1e16d97

Browse files
committed
Add meson.build script
Closes: issue #58 Signed-off-by: Nicholas Vinson <[email protected]>
1 parent fffbdf1 commit 1e16d97

File tree

6 files changed

+88
-25
lines changed

6 files changed

+88
-25
lines changed

.github/workflows/run_test.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
name: 'wgetpaste test runner'
22
on: [pull_request, push]
33
jobs:
4-
run-test:
5-
name: 'Run test/test.sh'
4+
run-tests:
5+
strategy:
6+
matrix:
7+
test: [test, test_ansi]
8+
name: "Run test/${{ matrix.test }}"
69
runs-on: ubuntu-latest
710
steps:
8-
- uses: actions/checkout@v3
9-
- run: test/test.sh
10-
shell: bash
11-
run-test-ansi:
12-
name: 'Run test/test_ansi.sh'
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v3
16-
- name: 'Install ansifilter'
11+
- name: 'Checkout repository'
12+
uses: actions/checkout@v4
13+
14+
- name: 'Install dependencies'
1715
run: |
1816
sudo apt-get update
19-
sudo apt-get install ansifilter
20-
- run: test/test_ansi.sh
17+
sudo apt-get install meson ${{ matrix.test == 'test_ansi' && 'ansifilter' || '' }}
18+
shell: bash
19+
20+
- name: 'Build wgetpaste'
21+
run: |
22+
mkdir build
23+
meson setup build --prefix="/"
2124
shell: bash
25+
26+
- run: meson test -C ./build ${{ matrix.test }}

meson.build

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
project(
2+
'wgetpaste',
3+
license: 'MIT',
4+
license_files: 'LICENSE',
5+
version: '2.35.0',
6+
meson_version: '>=1.1.0',
7+
)
8+
9+
config_data = configuration_data()
10+
config_data.set('WGETPASTE_SHEBANG', get_option('shebang'))
11+
config_data.set('WGETPASTE_VERSION', meson.project_version())
12+
configure_file(
13+
output: 'wgetpaste',
14+
input: 'wgetpaste',
15+
configuration: config_data,
16+
install: true,
17+
install_dir: get_option('bindir'),
18+
install_mode: 'rwxr-xr-x'
19+
)
20+
21+
install_data(
22+
'_wgetpaste',
23+
install_dir: get_option('datadir') / get_option('zsh-completions-dir'),
24+
install_mode: 'rw-r--r--'
25+
)
26+
27+
test_runner = find_program('test/test.sh')
28+
test(
29+
'test',
30+
test_runner,
31+
timeout: 0,
32+
env: [
33+
'MESON_BUILD_ROOT=' + meson.project_build_root()
34+
]
35+
)
36+
37+
test_runner = find_program('test/test_ansi.sh')
38+
test(
39+
'test_ansi',
40+
test_runner,
41+
timeout: 0,
42+
env: [
43+
'MESON_BUILD_ROOT=' + meson.project_build_root()
44+
]
45+
)

meson.options

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
option(
2+
'shebang',
3+
type: 'string',
4+
value: '/usr/bin/env bash',
5+
description: 'Specify shebang line for wgetpaste script'
6+
)
7+
option('zsh-completions-dir',
8+
type: 'string',
9+
value: 'zsh/site-functions',
10+
description: 'Specify location of zsh-completions directory (relative to datadir)'
11+
)

test/test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# Don't assume the test is being run from the same directory as the script
88
TEST_DIR="$(dirname "$0")"
9+
WGETPASTE="${MESON_BUILD_ROOT}/wgetpaste"
910
TEST_FILE="$TEST_DIR/test.txt"
1011
DL_DIR="$(mktemp -q --tmpdir -d wgetpaste_test.XXXXX)"
1112
# Services to hard skip
@@ -30,7 +31,7 @@ echo "Using download directory: $DL_DIR"
3031

3132
# Post test file into each service (if possible)
3233
# Download the resulting paste into /tmp/wgetpaste_test.XXXXX/<service>.txt
33-
for serv in $("$TEST_DIR"/../wgetpaste -S --completions); do
34+
for serv in $("$WGETPASTE" -S --completions); do
3435
# Hard skips
3536
for hs in "${!HARD_SKIPS[@]}"; do
3637
if [ "$serv" == "$hs" ]; then
@@ -45,7 +46,7 @@ for serv in $("$TEST_DIR"/../wgetpaste -S --completions); do
4546
# Log deleted at the end of each loop unless error other than 401
4647
echo -n "Posting to $serv: "
4748
ERROR_LOG="$DL_DIR/$serv-error.log"
48-
URL="$("$TEST_DIR"/../wgetpaste -r -s "$serv" -v "$TEST_FILE" 2>"$ERROR_LOG")"
49+
URL="$("$WGETPASTE" -r -s "$serv" -v "$TEST_FILE" 2>"$ERROR_LOG")"
4950
STATUS="$?"
5051

5152
# Skip failed posts (eg, not authorized for GitHub/GitLab, service error)

test/test_ansi.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Don't assume the test is being run from the same directory as the script
99
TEST_DIR="$(dirname "$0")"
10+
WGETPASTE="${MESON_BUILD_ROOT}/wgetpaste"
1011
ANSI_FILE="$TEST_DIR/red.txt"
1112
NOANSI_FILE="$TEST_DIR/red_no_ansi.txt"
1213
DL_DIR="$(mktemp -q --tmpdir -d wgetpaste_test_ansi.XXXXX)"
@@ -30,7 +31,7 @@ fi
3031
echo "Using download directory: $DL_DIR"
3132

3233
# Post test file into each service until one succeeds
33-
for serv in $("$TEST_DIR"/../wgetpaste -S --completions); do
34+
for serv in $("$WGETPASTE" -S --completions); do
3435
# Hard skips
3536
for hs in "${!HARD_SKIPS[@]}"; do
3637
if [ "$serv" == "$hs" ]; then
@@ -44,7 +45,7 @@ for serv in $("$TEST_DIR"/../wgetpaste -S --completions); do
4445
# Log deleted at the end of each loop unless error other than 401
4546
echo -n "Posting to $serv: "
4647
ERROR_LOG="$DL_DIR/$serv-error.log"
47-
URL="$("$TEST_DIR"/../wgetpaste -r -s "$serv" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
48+
URL="$("$WGETPASTE" -r -s "$serv" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
4849
STATUS="$?"
4950

5051
# Skip failed posts (eg, not authorized for GitHub/GitLab, service error)
@@ -96,7 +97,7 @@ fi
9697
sleep 1
9798
echo -n "Pasting command output with ANSI stripping (cat): "
9899
ERROR_LOG="$DL_DIR/command-noansi-error.log"
99-
URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
100+
URL="$("$WGETPASTE" -N -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
100101
if [ $? -ne 0 ]; then
101102
echo "FAILED!"
102103
FAILED_PASTE=$((FAILED_PASTE + 1))
@@ -118,7 +119,7 @@ fi
118119
sleep 1
119120
echo -n "Pasting command output without ANSI stripping (cat): "
120121
ERROR_LOG="$DL_DIR/command-ansi-error.log"
121-
URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
122+
URL="$("$WGETPASTE" -A -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
122123
if [ $? -ne 0 ]; then
123124
echo "FAILED!"
124125
FAILED_PASTE=$((FAILED_PASTE + 1))
@@ -141,7 +142,7 @@ fi
141142
sleep 1
142143
echo -n "Pasting stdin with ANSI stripping (cat | wgetpaste): "
143144
ERROR_LOG="$DL_DIR/stdin-noansi-error.log"
144-
URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v 2>"$ERROR_LOG")"
145+
URL="$(cat "$ANSI_FILE" | "$WGETPASTE" -N -r -s "$WORKING" -v 2>"$ERROR_LOG")"
145146
if [ $? -ne 0 ]; then
146147
echo "FAILED!"
147148
FAILED_PASTE=$((FAILED_PASTE + 1))
@@ -160,7 +161,7 @@ fi
160161
sleep 1
161162
echo -n "Pasting stdin without ANSI stripping (cat | wgetpaste): "
162163
ERROR_LOG="$DL_DIR/stdin-ansi-error.log"
163-
URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v 2>"$ERROR_LOG")"
164+
URL="$(cat "$ANSI_FILE" | "$WGETPASTE" -A -r -s "$WORKING" -v 2>"$ERROR_LOG")"
164165
if [ $? -ne 0 ]; then
165166
echo "FAILED!"
166167
FAILED_PASTE=$((FAILED_PASTE + 1))
@@ -180,7 +181,7 @@ fi
180181
sleep 1
181182
echo -n "Pasting a file with ANSI stripping: "
182183
ERROR_LOG="$DL_DIR/file-noansi-error.log"
183-
URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
184+
URL="$("$WGETPASTE" -N -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
184185
if [ $? -ne 0 ]; then
185186
echo "FAILED!"
186187
FAILED_PASTE=$((FAILED_PASTE + 1))
@@ -199,7 +200,7 @@ fi
199200
sleep 1
200201
echo -n "Pasting a file without ANSI stripping: "
201202
ERROR_LOG="$DL_DIR/file-ansi-error.log"
202-
URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
203+
URL="$("$WGETPASTE" -A -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
203204
if [ $? -ne 0 ]; then
204205
echo "FAILED!"
205206
FAILED_PASTE=$((FAILED_PASTE + 1))

wgetpaste

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env bash
1+
#!@WGETPASTE_SHEBANG@
22
# A Script that automates pasting to a number of pastebin services
33
# relying only on bash, sed, coreutils (mktemp/sort/tr/wc/whoami/tee) and wget
44
# Copyright (c) 2007-2016 Bo Ørsted Andresen <[email protected]>
55

6-
VERSION="2.33"
6+
VERSION="@WGETPASTE_VERSION@"
77

88
# don't inherit LANGUAGE from the env
99
unset LANGUAGE

0 commit comments

Comments
 (0)