Gentoo Archives: gentoo-dev

From: Donnie Berkholz <dberkholz@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] A unit-testing prototype
Date: Mon, 26 May 2008 09:47:15
Message-Id: 20080526094710.GB11722@comet
1 Hi everyone,
2
3 A while back, vapier added some tests for the toolchain-funcs eclass to
4 /usr/portage/eclass/tests/. I really like the idea, and I recently
5 discovered an xUnit-style unit-testing framework for shell scripts
6 called ShUnit2. I played with it a little and made a couple of
7 prototypes. Take a look and see what you think.
8
9 To get started:
10
11 layman -f -o http://gechi-overlay.sf.net/layman.xml -a gechi
12 emerge shunit2
13 sed -i -e "/^__SHUNIT_SHELL_FLAGS/s:u::g" /usr/share/shunit2/shunit2
14
15 Download the attached files to /usr/portage/eclass/tests, make 'em
16 executable and run 'em. The output looks something like this:
17
18 donnie@comet $ ./toolchain-funcs-shunit.sh
19 #
20 # Performing tests
21 #
22 test-tc-arch-kernel
23 test-tc-arch
24
25 #
26 # Test report
27 #
28 tests passed: 71 100%
29 tests failed: 0 0%
30 tests skipped: 0 0%
31 tests total: 71 100%
32
33 donnie@comet $ ./x-modular-shunit.sh
34 #
35 # Performing tests
36 #
37 test-x-modular_specs_check
38 test-x-modular_dri_check
39 ASSERT:DRIVER='yes' IUSE='dri' USE='dri' BUILT_WITH='yes'
40 test-x-modular_server_supports_drivers_check
41 ASSERT:DRIVER='yes' HAS_VER='yes' BUILT_WITH='yes'
42
43 #
44 # Test report
45 #
46 tests passed: 28 93%
47 tests failed: 2 7%
48 tests skipped: 0 0%
49 tests total: 30 100%
50
51
52 What do you think?
53
54 Thanks,
55 Donnie

Attachments

File name MIME type
toolchain-funcs-shunit.sh application/x-sh
x-modular-shunit.sh application/x-sh
tests-common.sh application/x-sh

Replies

Subject Author
Re: [gentoo-dev] A unit-testing prototype Donnie Berkholz <dberkholz@g.o>