Skip to content

Commit cebefc2

Browse files
committed
tests: Fix old test scripts
1 parent cf3f0f9 commit cebefc2

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

tests/echo.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@ set -eux
44

55
## basic echo
66

7-
result="$(./echo.py foo bar)"
7+
result="$(python -m userland echo foo bar)"
88

99
test "${result}" = 'foo bar'
1010

1111
## double hyphen
1212

13-
result="$(./echo.py -- foo)"
13+
result="$(python -m userland echo -- foo)"
1414

1515
test "${result}" = '-- foo'
1616

1717
## multiple double hyphens
1818

19-
result="$(./echo.py -- foo --)"
19+
result="$(python -m userland echo -- foo --)"
2020

2121
test "${result}" = '-- foo --'
2222

2323
## unknown option
2424

25-
result="$(./echo.py -x foo)"
25+
result="$(python -m userland echo -x foo)"
2626

2727
test "${result}" = '-x foo'
2828

2929
## unknown option and double hyphen
3030

31-
result="$(./echo.py -x -- foo)"
31+
result="$(python -m userland echo -x -- foo)"
3232

3333
test "${result}" = '-x -- foo'
3434

3535
## escape codes
3636

37-
result="$(./echo.py -e 'foo \x41' '\0102')"
37+
result="$(python -m userland echo -e 'foo \x41' '\0102')"
3838

3939
test "${result}" = 'foo A B'
4040

4141
## no arguments
4242

43-
result="$(./echo.py)"
43+
result="$(python -m userland echo)"
4444

4545
test "${result}" = "$(printf '\n')"
4646

4747
## empty arguments
4848

49-
result="$(./echo.py '' foo '' bar '' '')"
49+
result="$(python -m userland echo '' foo '' bar '' '')"
5050

5151
test "${result}" = ' foo bar '
5252

5353
## no trailing newline
5454

55-
n_lines="$(./echo.py -n 'foo' | wc -l)"
55+
n_lines="$(python -m userland echo -n 'foo' | wc -l)"
5656

5757
test "${n_lines}" = 0
5858

tests/factor.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22

33
set -eux
44

5-
start="$(date -u +%s)"
6-
7-
for n in $(seq 0 1000); do
8-
test "$(./factor.py "${n}")" = "$(factor "${n}")"
9-
done
10-
11-
end="$(date -u +%s)"
12-
printf '%.1f s elapsed\n' $(( end - start ))
5+
numbers="$(seq 0 10000)"
6+
test "$(python -m userland factor ${numbers})" = "$(factor ${numbers})"
137

148
exit 0

tests/truncate.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,41 @@ get_size() {
1414

1515
echo 'foo bar' > "${tempdir}"/a
1616

17-
./truncate.py -s 3 "${tempdir}"/a
17+
python -m userland truncate -s 3 "${tempdir}"/a
1818

1919
test "$(cat "${tempdir}"/a)" = 'foo'
2020

2121
## size extension
2222

23-
./truncate.py -s +7 "${tempdir}"/a
23+
python -m userland truncate -s +7 "${tempdir}"/a
2424

2525
size="$(get_size "${tempdir}"/a)"
2626
test "${size}" = 10
2727

2828
## ensure minimum size
2929

30-
./truncate.py -s '>5' "${tempdir}"/a
30+
python -m userland truncate -s '>5' "${tempdir}"/a
3131

3232
size="$(get_size "${tempdir}"/a)"
3333
test "${size}" = 10
3434

3535
## truncate to maximum size
3636

37-
./truncate.py -s '<8' "${tempdir}"/a
37+
python -m userland truncate -s '<8' "${tempdir}"/a
3838

3939
size="$(get_size "${tempdir}"/a)"
4040
test "${size}" = 8
4141

4242
## round size to multiple
4343

44-
./truncate.py -s %5 "${tempdir}"/a
44+
python -m userland truncate -s %5 "${tempdir}"/a
4545

4646
size="$(get_size "${tempdir}"/a)"
4747
test "${size}" = 10
4848

4949
## ensure size is multiple
5050

51-
./truncate.py -s /2 "${tempdir}"/a
51+
python -m userland truncate -s /2 "${tempdir}"/a
5252

5353
size="$(get_size "${tempdir}"/a)"
5454
test "${size}" = 10
@@ -57,21 +57,21 @@ test "${size}" = 10
5757

5858
touch "${tempdir}"/b
5959

60-
./truncate.py -r "${tempdir}"/a "${tempdir}"/b
60+
python -m userland truncate -r "${tempdir}"/a "${tempdir}"/b
6161

6262
size="$(get_size "${tempdir}"/b)"
6363
test "${size}" = 10
6464

6565
## truncate with reference file and size adjustment
6666

67-
./truncate.py -r "${tempdir}"/a -s +10 "${tempdir}"/b
67+
python -m userland truncate -r "${tempdir}"/a -s +10 "${tempdir}"/b
6868

6969
size="$(get_size "${tempdir}"/b)"
7070
test "${size}" = 20
7171

7272
## truncate with block size
7373

74-
./truncate.py -s 0 -o "${tempdir}"/a
74+
python -m userland truncate -s 0 -o "${tempdir}"/a
7575

7676
test ! -s "${tempdir}"/a
7777

0 commit comments

Comments
 (0)