Created
May 5, 2011 19:39
-
-
Save michaelfeathers/957739 to your computer and use it in GitHub Desktop.
Generate stubs that tell you when they are called. Helpful when componentizing for test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gccmock - generate exploding link stubs from linker error messages | |
# | |
# Usage: gcc [files] 2>&1 ruby gccmock.rb > [filename].c | |
LINK_SYMBOL = /.*"_([_a-z0-9]*)",/ | |
puts "#include <assert.h>\n" | |
puts "#define EXPLODE(name) void name() { assert(!\"unexpected call\"); }" | |
puts ARGF.select { |line| LINK_SYMBOL =~ line } \ | |
.map { |line| LINK_SYMBOL.match(line)[1] } \ | |
.uniq \ | |
.sort \ | |
.map { |name| "EXPLODE(#{name});" } \ | |
.join($/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment