How can I run a t.test in this situation of two processes having binary outcomes I have two processes, lets call them A and B. I want to infer whether their population means are equal for their experimental outcomes. Both of these processes generate 1s and 0s only. That is, the outcome is binary. 
My situation is similar to using two different processes to flip a coin a few times. The idea is to compare the experimental outcomes of these two processes.
I will show two simple cases to illustrate the problem. In the first case, function t.test() of the R language's stats package runs just fine when t-testing these two outcomes:
> t.test(rep(1,5), c(rep(1,4),0))

    Welch Two Sample t-test

data:  rep(1, 5) and c(rep(1, 4), 0)
t = 1, df = 4, p-value = 0.3739
...

IN the second case, for some reason the t.test will not run, and an error is returned, when t-testing these two outcomes:
> t.test(rep(1,5), rep(1,5))
Error in t.test.default(rep(1, 5), rep(1, 5)) : 
  data are essentially constant

I will need a workaround to effectively run a t-test in case 2.  I do not have a human available to always look at the data before deciding whether to run the t.test.  
I have done some research and saw that some people write exception handling code in these situations. Do I really need to write my own t.test implementation, such as by wrapping exception handling code around the standard stats t.test and then doing some things depending on various things in the data (I don't know what exactly)?  If there  is a different implementation available somewhere then that might be the best solution.  I am not confident in my ability to write new t.test implementations accurately.
These two cases represent entirely possible and realistic experimental data in my situation.
Edit:  Additional background seems to be interesting to the community. Here you go.
Thanks to all for so many questions!  Let me see if I can provide some of the context the community seems to be wanting.  In the experiments in question, we might have a scenario where my users wish to infer whether technique A for studying for SAT exams is better than technique B. IN this case there will be (effectively) continuous outcomes in the form of the mean SAT score by groups A and B. In a different scenario my users want to analyze, there may be an AB test of a web site wherein the user wants to try to get more people to open the email and to do so the firm sends out an A subject on  some emails, and a B subject on emails to different group of customers. Whether the customer opened the email is a success, encoded as 1, failure being the recipient did not open the email and this would be encoded most naturally as 0. A comparison of the group means would be interesting, as a significant difference in mean success rate of opening emails could cause the user's firm to change they way they write email subject lines. Hope this helps.
 A: A t-test is appropriate for continuous data that is normally distributed. If you have binary data, you need to do a proportion test or binomial test. 
You point out in the comments that you don't know if the data are always binary or continuous. In R it is not complicated to write a code to automatically determine which type of data you have, and then run appropriate statistics.
For example:
group<-c(rep(0,100),rep(1,100))
continuous<-rnorm(n=200,mean=1+2*group)
binary<-rbinom(200,1,prob=.2+.3*group)


test<-function(data) {
  if (length(table(data[,1]))==2) {
    chisq.test(table(data[,1:2]))$p.value
  } else {
  t.test(data[,1]~data[,2])
  }
}

test(cbind(binary,group))
test(cbind(continuous,group))

I used a $\chi^2$ test not a proportion test because I always forget the prop.test syntax, but you can replace that easily. The results should be the same.
The case where you have no variability in the outcomes is going to be tricky, because in general the probability of a binary variable being 0 or 1 is undefined. In a small sample like you provided in the example, it is possible that you will have all 1's or 0's - unfortunately, I believe that you cannot calculate statistics from that. Someone smarter than me may give you better guidance on what to do with that, but you may need to do a simple proportion comparison without a statistical test.
A: Based on your comments, I think I have an answer for you. It seems like for the processes you currently have, you have binary outcomes, but that there will be other processes which will not. You would like to use a t.test to analyze the results.
The issue that you're having is that the t.test is not designed for use on binary outcomes. It's designed for use on continuous outcomes. The formula for a t-test is:
t = (x1-x2)/(s*sqrt(2/n))
s represents the pooled standard deviation. You're encountering the error you have because the two samples in part 2 have no standard deviation - they're constant. This means that to generate the test statistics you're dividing by 0. Which, you know, makes the universe explode. If s is too small then the t value will be huge no matter what the difference between the two sample means (unless the sample means are identical, as in your example). The t-test becomes a moot point because either the sample means are identical, in which case the p-value would be 1, or the sample means are different by any amount, in which case the p-value would be so small as to be functionally 0.
In other words, you cannot effectively run a t-test in case 2. I'd be interested in seeing the sources you have found where people do workarounds for this.
Your examples at the end do help a lot. In the success/failure example (which is analogous to the examples you provided) you should use a proportion test instead of a t-test. In the SAT test, with continuous scores, you should use the t-test. It is highly unlikely that you would encounter a situation where there was so little variability in the SAT scores that you would see this error happen again. It's possible, but highly, highly, highly unlikely except with a very, very small sample size. In which case my advice is to increase the sample size :)
A: If the outcomes of both processes is binary, I'd recommend using prop.test to determine if the processes have significantly different outcome probabilities.  The documentation for it can be found here:
https://stat.ethz.ch/R-manual/R-patched/library/stats/html/prop.test.html
