Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2018-03-30 22:35:45 +0300
committerGitHub <noreply@github.com>2018-03-30 22:35:45 +0300
commit73e8a1f8130a792e6661819e6236533576fca45a (patch)
tree4405143abaa44a03d12ca6115df53d11bccbaff8 /src/System.Private.Xml
parent94fe40287a5f61e96b09acaabacce55210ced8a0 (diff)
Using random string for temp files (#28589)
Diffstat (limited to 'src/System.Private.Xml')
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs38
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs2
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs2
3 files changed, 24 insertions, 18 deletions
diff --git a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
index 0c6dfaf71d..2f2649b529 100644
--- a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
+++ b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
@@ -609,18 +609,13 @@ namespace System.Xml.Tests
AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><result>123</result>";
+ string fileName = GetType().Name + "_" + Path.GetRandomFileName();
+ string testFile = Path.Combine(Path.GetTempPath(), fileName);
+ string xmlFile = FullFilePath(fileName);
// copy file on the local machine
try
{
- string tempPath = Path.GetTempPath();
- string testFile = Path.Combine(tempPath, "xmlResolver_document_function.xml");
- if (File.Exists(testFile))
- {
- File.SetAttributes(testFile, FileAttributes.Normal);
- File.Delete(testFile);
- }
- string xmlFile = FullFilePath("xmlResolver_document_function.xml");
File.Copy(xmlFile, testFile, true);
}
catch (Exception e)
@@ -629,6 +624,14 @@ namespace System.Xml.Tests
_output.WriteLine("Could not copy file to local. Some other issues prevented this test from running");
return; //TEST_SKIPPED;
}
+ finally
+ {
+ if (File.Exists(testFile))
+ {
+ File.SetAttributes(testFile, FileAttributes.Normal);
+ File.Delete(testFile);
+ }
+ }
// copy file on the local machine (this is now done with createAPItestfiles.js, see Oasys scenario.)
if (LoadXSL("xmlResolver_document_function_absolute_uri.xsl", xslInputType, readerType) == 1)
@@ -2522,18 +2525,13 @@ namespace System.Xml.Tests
AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><result>123</result>";
+ string fileName = GetType().Name + "_" + Path.GetRandomFileName();
+ string testFile = Path.Combine(Path.GetTempPath(), fileName);
+ string xmlFile = FullFilePath(fileName);
// copy file on the local machine
try
{
- string tempPath = Path.GetTempPath();
- string testFile = Path.Combine(tempPath, "xmlResolver_document_function.xml");
- if (File.Exists(testFile))
- {
- File.SetAttributes(testFile, FileAttributes.Normal);
- File.Delete(testFile);
- }
- string xmlFile = FullFilePath("xmlResolver_document_function.xml");
File.Copy(xmlFile, testFile, true);
}
catch (Exception e)
@@ -2542,6 +2540,14 @@ namespace System.Xml.Tests
_output.WriteLine("Could not copy file to local. Some other issues prevented this test from running");
return; //TEST_SKIPPED;
}
+ finally
+ {
+ if (File.Exists(testFile))
+ {
+ File.SetAttributes(testFile, FileAttributes.Normal);
+ File.Delete(testFile);
+ }
+ }
if (LoadXSL("xmlResolver_document_function_absolute_uri.xsl", xslInputType, readerType) == 1)
{
diff --git a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
index e06d0a74e2..f5c7c15859 100644
--- a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
+++ b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
@@ -76,7 +76,7 @@ namespace System.Xml.Tests
static XsltApiTestCaseBase2()
{
// Replace absolute URI in xmlResolver_document_function.xml based on the environment
- string targetFile = Path.Combine(Path.GetTempPath(), "xmlResolver_document_function.xml");
+ string targetFile = Path.Combine(Path.GetTempPath(), typeof(XsltApiTestCaseBase2) + "_" + Path.GetRandomFileName());
string xslFile = Path.Combine("TestFiles", FilePathUtil.GetTestDataPath(), "XsltApiV2", "xmlResolver_document_function_absolute_uri.xsl");
XmlDocument doc = new XmlDocument();
doc.Load(xslFile);
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs
index 010efa92a2..3ef33bd4fc 100644
--- a/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs
@@ -49,7 +49,7 @@ namespace System.Xml.Tests
public class XsltApiTestCaseBase : FileCleanupTestBase
{
private const string XmlResolverDocumentName = "xmlResolver_document_function.xml";
- private static readonly string s_temporaryResolverDocumentFullName = Path.Combine(Path.GetTempPath(), "XslTransformApi", XmlResolverDocumentName);
+ private static readonly string s_temporaryResolverDocumentFullName = Path.Combine(Path.GetTempPath(), typeof(XsltApiTestCaseBase) + "_" + Path.GetRandomFileName());
private static readonly object s_temporaryResolverDocumentLock = new object();
// Generic data for all derived test cases