Is there a way to let LaTeX automatically set the page size to fit any given content? To be clear, the code should work for ALL types of contents and both crop and stretch the page depending on its size.
For example, this code:
\documentclass[varwidth=true, border=10pt]{standalone}
\begin{document}
\begin{tabular}{cccc}
test & test & test & test
\end{tabular}
\end{document}
works as long as the table is not too large, but if the width is increased, for example like this:
\documentclass[varwidth=true, border=10pt]{standalone}
\begin{document}
\begin{tabular}{cccc}
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest & test & test & test
\end{tabular}
\end{document}
then the page is not (sufficiently) increased in size, but the table is cut off on the right side.
Is there a good way to do this for all cases?

varwidth=\maxdimen, but there is an interesting effect if you need to set text in paragraphs (AKA the main purpose of usingvarwidth). ;-) – Paul Gessler Mar 14 '16 at 17:57