Skip to content

Commit

Permalink
Remove the path from the basename. Fixes #33.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhujer committed May 12, 2024
1 parent b207f61 commit f97f4b0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
29 changes: 21 additions & 8 deletions bin/aceunit
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ loadFixtures() {

loadFixture() {
file=$1
basename=${file%.o}
basename=$(getBasename $file)
symbols=( $(getSymbols $file $prefix) )
beforeAll[$basename]=$( printf '%s\n' "${symbols[@]}" | grep "^${prefix}beforeAll" )
afterAll[$basename]=$( printf '%s\n' "${symbols[@]}" | grep "^${prefix}afterAll" )
Expand All @@ -160,6 +160,19 @@ loadFixture() {
testcases[$basename]=$( printf '%s\n' "${symbols[@]}" | grep "^${prefix}test" )
}

getBasename() {
result=${1##*/}
echo ${result%.o}
}

fixtureName() {
echo fixture_$1
}

testcasesName() {
echo testcases_$1
}

generateHeader() {
cat << END
#include <aceunit.h>
Expand All @@ -169,7 +182,7 @@ END

generateExterns() {
for file in $fixtures; do
basename=${file%.o}
basename=$(getBasename $file)
if [ -z "${testcases[$basename]}" ]; then echo "$file: warning: No test cases found." 1>&2; fi
for extern in ${beforeAll[$basename]} ${afterAll[$basename]} ${beforeEach[$basename]} ${afterEach[$basename]} ${testcases[$basename]}; do
echo "extern void $extern(void);"
Expand All @@ -179,20 +192,20 @@ generateExterns() {

generateFxitureStructures() {
for file in $fixtures; do
basename=${file%.o}
basename=$(getBasename $file)
echo
echo "const aceunit_func_t testcases_${basename}[] = {"
echo "const aceunit_func_t $(testcasesName $basename)[] = {"
for testcase in ${testcases[$basename]}; do echo " $testcase,"; done
cat << END
NULL,
};
const AceUnit_Fixture_t fixture_$basename = {
const AceUnit_Fixture_t $(fixtureName $basename) = {
${beforeAll[$basename]:-NULL},
${afterAll[$basename]:-NULL},
${beforeEach[$basename]:-NULL},
${afterEach[$basename]:-NULL},
testcases_$basename,
$(testcasesName $basename),
};
END
Expand All @@ -204,8 +217,8 @@ generateFixtureTable() {
const AceUnit_Fixture_t *${name}[] = {
END
for file in $fixtures; do
basename=${file%.o}
echo " &fixture_$basename,"
basename=$(getBasename $file)
echo " &$(fixtureName $basename),"
done
cat <<END
NULL,
Expand Down
28 changes: 14 additions & 14 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ libaceunit-setjmp.a: AceUnit_Main.o AceUnit_Runner.o AceUnit_SetJmpRunner.o

test: test_SimpleRunner test_AbortRunner test_ForkRunner test_SetJmpRunner

test_SimpleRunner: AceUnit_SimpleRunner_Test
./AceUnit_SimpleRunner_Test
test_SimpleRunner: test/AceUnit_SimpleRunner_Test
test/AceUnit_SimpleRunner_Test

test_AbortRunner: AceUnit_AbortRunner_Test
./AceUnit_AbortRunner_Test
test_AbortRunner: test/AceUnit_AbortRunner_Test
test/AceUnit_AbortRunner_Test

test_ForkRunner: AceUnit_ForkRunner_Test
./AceUnit_ForkRunner_Test
test_ForkRunner: test/AceUnit_ForkRunner_Test
test/AceUnit_ForkRunner_Test

test_SetJmpRunner: AceUnit_SetJmpRunner_Test
./AceUnit_SetJmpRunner_Test
test_SetJmpRunner: test/AceUnit_SetJmpRunner_Test
test/AceUnit_SetJmpRunner_Test

AceUnit_SimpleRunner_Test: AceUnit_SimpleRunner_Test.o libaceunit-simple.a
AceUnit_AbortRunner_Test: AceUnit_AbortRunner_Test.o AceUnit_AbortRunner_Fixture.o libaceunit-abort.a
AceUnit_ForkRunner_Test: AceUnit_ForkRunner_Test.o AceUnit_ForkRunner_Fixture.o libaceunit-fork.a
AceUnit_SetJmpRunner_Test: AceUnit_SetJmpRunner_Test.o AceUnit_SetJmpRunner_Fixture.o libaceunit-setjmp.a
test/AceUnit_SimpleRunner_Test: test/AceUnit_SimpleRunner_Test.o libaceunit-simple.a
test/AceUnit_AbortRunner_Test: test/AceUnit_AbortRunner_Test.o test/AceUnit_AbortRunner_Fixture.o libaceunit-abort.a
test/AceUnit_ForkRunner_Test: test/AceUnit_ForkRunner_Test.o test/AceUnit_ForkRunner_Fixture.o libaceunit-fork.a
test/AceUnit_SetJmpRunner_Test: test/AceUnit_SetJmpRunner_Test.o test/AceUnit_SetJmpRunner_Fixture.o libaceunit-setjmp.a

%_Fixture.c: %_Test.o
test/%_Fixture.c: test/%_Test.o
$(ACEUNIT) $(ACEUNIT_FLAGS) $^ >$@

.PHONY: clean
## clean: Removes all generated files.
clean::
$(RM) *.[adios] *.bc AceUnit_*Runner_Test
$(RM) *.[adios] test/*.[adios] *.bc test/AceUnit_*Runner_Test

.PHONY: help
## help: Print this help text.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f97f4b0

Please sign in to comment.