summaryrefslogtreecommitdiff
path: root/tools/slang-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-06-24 16:08:08 -0400
committerGitHub <noreply@github.com>2022-06-24 16:08:08 -0400
commitf1b41a71be938b8711ee0fff0130185f512d2336 (patch)
tree29ad602a61968e1aacdf8424afc0c89defdb4330 /tools/slang-test
parentc12c0ad7fbb0272283f224493dbc28d9d60e7b91 (diff)
Handling of temporary files (#2299)
* #include an absolute path didn't work - because paths were taken to always be relative. * Work around windows issue with temporary file clash. * Handle the temporary file path actually creates a file. * Fix typo. * Fix typo in linux for temporary file. * Add unit test for io. Tests generateTemporary operation.
Diffstat (limited to 'tools/slang-test')
-rw-r--r--tools/slang-test/slang-test-main.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 7e504da74..ea5ada4b0 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1203,15 +1203,21 @@ static SlangResult _executeBinary(const UnownedStringSlice& hexDump, ExecuteResu
List<uint8_t> data;
SLANG_RETURN_ON_FAIL(HexDumpUtil::parseWithMarkers(hexDump, data));
+ TemporaryFileSet temporaryFileSet;
+
// Need to write this off to a temporary file
- String fileName;
- SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice("slang-test"), fileName));
+
+ String temporaryLockPath;
+
+ SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice("slang-test"), temporaryLockPath));
+ String fileName = temporaryLockPath;
+ // And the temporary lock path
+ temporaryFileSet.add(temporaryLockPath);
fileName.append(Process::getExecutableSuffix());
- TemporaryFileSet temporaryFileSet;
temporaryFileSet.add(fileName);
-
+
{
ComPtr<ISlangWriter> writer;
SLANG_RETURN_ON_FAIL(FileWriter::createBinary(fileName.getBuffer(), 0, writer));
@@ -1979,8 +1985,12 @@ static SlangResult _loadAsSharedLibrary(const UnownedStringSlice& hexDump, Tempo
SLANG_RETURN_ON_FAIL(HexDumpUtil::parseWithMarkers(hexDump, data));
// Need to write this off to a temporary file
- String fileName;
- SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice("slang-test"), fileName));
+
+ String temporaryLockPath;
+ SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice("slang-test"), temporaryLockPath));
+ inOutTemporaryFileSet.add(temporaryLockPath);
+
+ String fileName = temporaryLockPath;
// Need to work out the dll name
String sharedLibraryName = SharedLibrary::calcPlatformPath(fileName.getUnownedSlice());