A sure test, giving an incontestable result.
Gold prospectors and dealers need to be able to distinguish gold from base metal. The original acid test was developed in the late 18th century and relied on nitric acid's ability to dissolve other metals more readily than gold. To confirm that a find was gold it was given 'the acid test'. A test sample was used to mark a touchstone and the degree to which it dissolved when the acid was added determined whether it was gold. Various other later tests also used acid and these are all called 'acid tests'.
The earliest citation I have found of a figurative use of the phrase (that is, one where no actual test is performed) is from the Wisconsin paper The Columbia Reporter, November 1845:
"Twenty-four years of service demonstrates his ability to stand the acid test, as Gibson’s Soap Polish has done for over thirty years."
A punning variant of the term arose in the 1960s hippy community. Ken Kesey and his Merry Pranksters began holding 'Acid Test' parties in San Francisco in 1965. The attendees were serenaded by The Grateful Dead and given drinks of Kool-Aid spiked with lysergic acid diethylamide. 'Acid' was of course the colloquial name of LSD. It's not clear exactly what was being tested; survival possibly. The 'test' parties were referred to in Jefferson Airplane's 1965 A Song for All Seasons:
Since the acid test...
They say your drummer he's crazy as a loon
Last night they found him baying at the moon
For those who have never experienced the joys of Kool-Aid, with or without the mystery ingredient, it's a soft drink. Its original name was 'Fruit Smack'; perhaps that's what Kesey had in mind?
See other phrases that were coined in the USA.