dude, i have several suggestions, which get more relevent the more i hear about this story.
1. Snitches get Stiches. Learn it, live it.
2. Deny deny deny. never admit anything, ever.
3. Drink an assload of water, take a multi vitamin before any drug test, even if you "know" you havnt smoked in a while and are clean. its just a good habit, even for everyday life, not just testing.
4. Snitches get Stiches. worth repeating.
5. Also, in your case, if your friend blabbed, either
a. Give him a savage beating
b. Tell teacher he is lying and is out to get you, place ALL blame on him
c. buy some Crack. place in his locker. call the cops.
d. All of the above.

PS. correct answer is D