much of which country? I live in the US and I've never been drug tested as a software engineer, nor have any of my peers or friends (unless you're getting a security clearance or something.)
I was a marijuana user at the time, so I took a competing offer that paid less (though ended up being a much better fit for me -- still with the company now 11 years later)
https://www.vice.com/en/article/3bjbgn/fake-drug-test-foilin...