Bring back the harness from SkSLGLSLTest as a testbed for debugging.

The code here is resuscitated from the GLSL testing harness at
http://review.skia.org/317771 . Testing and debugging in dm is simpler
than debugging skslc when we encounter compiler issues.

Change-Id: I492dd0bbd2f0ee0b3b6a1b5253da54d72dc1eb3b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319032
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/tests/SkSLGLSLTestbed.cpp b/tests/SkSLGLSLTestbed.cpp
new file mode 100644
index 0000000..baffd8b
--- /dev/null
+++ b/tests/SkSLGLSLTestbed.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/sksl/SkSLCompiler.h"
+
+#include "tests/Test.h"
+
+// Note that the optimizer will aggressively kill dead code and substitute constants in place of
+// variables, so we have to jump through a few hoops to ensure that the code in these tests has the
+// necessary side-effects to remain live. In some cases we rely on the optimizer not (yet) being
+// smart enough to optimize around certain constructs; as the optimizer gets smarter it will
+// undoubtedly end up breaking some of these tests. That is a good thing, as long as the new code is
+// equivalent!
+
+static void test(skiatest::Reporter* r, const SkSL::Program::Settings& settings, const char* src,
+                 SkSL::Program::Inputs* inputs,
+                 SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
+    SkSL::Compiler compiler;
+    SkSL::String output;
+    std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, SkSL::String(src),
+                                                                     settings);
+    if (!program) {
+        SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
+        REPORTER_ASSERT(r, program);
+    } else {
+        *inputs = program->fInputs;
+        REPORTER_ASSERT(r, compiler.toGLSL(*program, &output));
+        REPORTER_ASSERT(r, output != "");
+    }
+}
+
+static void test(skiatest::Reporter* r, const GrShaderCaps& caps, const char* src,
+                 SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
+    SkSL::Program::Settings settings;
+    settings.fCaps = &caps;
+    SkSL::Program::Inputs inputs;
+    test(r, settings, src, &inputs, kind);
+}
+
+DEF_TEST(SkSLGLSLTestbed, r) {
+    // Add in your SkSL here.
+    test(r,
+         *SkSL::ShaderCapsFactory::Default(),
+         R"__SkSL__(
+             void main() {
+                 sk_FragColor = half4(0);
+             }
+         )__SkSL__");
+}