summaryrefslogtreecommitdiffstats
path: root/tools/slang-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-08-20 09:43:59 -0400
committerGitHub <noreply@github.com>2019-08-20 09:43:59 -0400
commit7258ef4ddebd021208a019f6ee73edcda57a88f7 (patch)
tree30cccf48c8f03e59e48a2d265e05494238fe758d /tools/slang-test
parent3e78e4654cdf9556869325f2ed2da517f252d879 (diff)
User defined downstream compiler prelude (#1028)
* Added setDownstreamCompilerPrelude Renamed setPassThroughPath to setDownstreamCompilerPath. Fixed tests. Added prelude directory & code to TestToolUtil to setup default preludes for testing/command line apis. * Fix merge problem * Remove hacks to make prelude work by adding a search path as no longer needed with 'user prelude'. * Split up prelude into scalar intrinsics, and types. Use slang.h for main header. slang-cpp-prelude.h can now just include what it needs (relative to prelude directory) and define the few remaining things/work arounds. * Fix typo.
Diffstat (limited to 'tools/slang-test')
-rw-r--r--tools/slang-test/slang-test-main.cpp52
-rw-r--r--tools/slang-test/test-context.cpp1
2 files changed, 4 insertions, 49 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 63e2456d9..ff80c7ec0 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -32,7 +32,7 @@ using namespace Slang;
#include <stdarg.h>
#define SLANG_PRELUDE_NAMESPACE CPPPrelude
-#include "../../tests/cross-compile/slang-cpp-prelude.h"
+#include "../../prelude/slang-cpp-types.h"
// Options for a particular test
struct TestOptions
@@ -1388,54 +1388,6 @@ static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input)
return TestResult::Fail;
}
- String modulePath = _calcModulePath(input);
-
- // Find the target
- UnownedStringSlice targetExt = UnownedStringSlice::fromLiteral("c");
- Index index = cmdLine.findArgIndex(UnownedStringSlice::fromLiteral("-target"));
- if (index >= 0 && index + 1 < cmdLine.getArgCount())
- {
- targetExt = cmdLine.m_args[index + 1].value.getUnownedSlice();
- }
-
- // If output was C/C++ we should try compiling
- if (targetExt == "c" || targetExt == "cpp")
- {
- CPPCompiler::CompileOptions options;
- options.sourceType = (targetExt == "c") ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP;
-
- options.includePaths.add("tests/cross-compile");
-
- String actualOutput = exeRes.standardOutput;
-
- // Create a filename to write this out to
- String cppSource = modulePath + "." + targetExt;
- Slang::File::writeAllText(cppSource, actualOutput);
-
- // Okay we can now try compiling
-
- // Compile this source
- options.sourceFiles.add(cppSource);
- options.modulePath = modulePath;
- options.targetType = CPPCompiler::TargetType::SharedLibrary;
-
- CPPCompiler::Output output;
- if (SLANG_FAILED(compiler->compile(options, output)))
- {
- return TestResult::Fail;
- }
-
- if (output.getCountByType(CPPCompiler::Diagnostic::Type::Error) > 0)
- {
- return TestResult::Fail;
- }
- }
- else
- {
- // Can only be callable
- SLANG_ASSERT(targetExt == "callable" || targetExt == "host-callable");
- }
-
return TestResult::Pass;
}
@@ -2853,6 +2805,8 @@ SlangResult innerMain(int argc, char** argv)
TestContext context;
SLANG_RETURN_ON_FAIL(SLANG_FAILED(context.init()))
+ TestToolUtil::setSessionDefaultPrelude(argv[0], context.getSession());
+
auto& categorySet = context.categorySet;
// Set up our test categories here
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp
index 5da998f03..fe9bdbc0e 100644
--- a/tools/slang-test/test-context.cpp
+++ b/tools/slang-test/test-context.cpp
@@ -21,6 +21,7 @@ Result TestContext::init()
{
return SLANG_FAIL;
}
+
return SLANG_OK;
}