//[Ignore] // Bug # 475921 public void ResolveSourceFile_Test() { // Adjust DLRPATH and place a file in this directory // After looking at the source code I see that I need to leave off // the file extension. string tempFile = Path.GetTempFileName(); string newFile = Path.ChangeExtension(tempFile, ".py"); File.WriteAllText(newFile, "print \"Hello\""); //e.g., 'foo.py' string in dlrpath string fileNameWithExtension = Path.GetFileName(newFile); //e.g., 'foo' string though this file name doesn't exists string fileNameWithoutExtension = fileNameWithExtension.Replace(".py", ""); // Adjust the environment Environment.SetEnvironmentVariable("DLRPATH", Path.GetDirectoryName(newFile)); ScriptRuntimeSetup setup = new ScriptRuntimeSetup(true); setup.HostType = typeof(ScriptHostBasicSubTest); // Are HostArgs ment to be arguments to a loaded script i.e. // passing paramters to argv? setup.HostArguments = new object[] { "-f foo" }; // This throws exception ScriptRuntime aRuntime = ScriptRuntime.Create(setup); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)aRuntime.Host; // Search for 'foo' type name that is a success host.ResolveSourceFile(fileNameWithoutExtension); // Search for 'foo.py' type file fails host.ResolveSourceFile(fileNameWithExtension); }
public void Host_UninitializedRuntimeProperty() { // Setup test values // Create derived host instance but this is not associated with runtime? ScriptHostBasicSubTest myHost = new ScriptHostBasicSubTest(Path.GetFullPath(".")); // Verify correct runtime property. ScriptRuntime runtimeEnv = myHost.Runtime; }
[Ignore] // BUG - Currently blocked by lack of documentation for ScriptHost|PAL // (Investigate | file bug) public void Host_UninitializedPALProperty() { // Setup test values // Create derived host instance but this is not associated with runtime? ScriptHostBasicSubTest myHost = new ScriptHostBasicSubTest(Path.GetFullPath(".")); // Todo - Investigate this failure this could be by design // Verify correct PAL property -- Maybe blocked by bug 462717 PlatformAdaptationLayer testPAL = myHost.PlatformAdaptationLayer; }
public void Host_UninitializedPALProperty() { // Setup test values // Create derived host instance but this is not associated with runtime? ScriptHostBasicSubTest myHost = new ScriptHostBasicSubTest(Path.GetFullPath(".")); // Todo - Investigate this failure this could be by design // Verify correct PAL property -- Maybe blocked by bug 462717 PlatformAdaptationLayer testPAL = myHost.PlatformAdaptationLayer; }
//[Ignore] // See|File Host Config Bug/ResolveSourceFile public void ResolveSourceFile_WithSingleArg() { // Setup env for search. string tmpFileName = TestHelpers.CreateTempSourceFile("1+1", ".py"); // This could possbly enable the host to be aware of other search path ScriptRuntime newRuntimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), Path.GetDirectoryName(tmpFileName)); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)newRuntimeEnv.Host; ValidateResolveSourceFileSearchResult(host, tmpFileName, Path.GetFullPath(tmpFileName)); }
//[Ignore] // See|File Host Config Bug/ResolveSourceFile public void ResolveSourceFileName_LookForMissingFile() { //Need to find a name that is less likely to be in the path string missingFileName = "123sadfsssp__foo__.py"; // This could possble enable the host to be aware of other search path ScriptRuntime newRuntimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), "."); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)newRuntimeEnv.Host; // Verify search result ValidateResolveSourceFileNameSearchResult(host, missingFileName); }
//[Ignore] // BUG - This test is blocked by lack of DLRPATH DLR/Config support public void ResolveSourceFileName_OverrideTestNameIsUnchanged() { // Setup env for search. string tmpFileName = TestHelpers.CreateTempSourceFile("1+1", ".py"); // This could possble enable the host to be aware of other search path ScriptRuntime newRuntimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), Path.GetDirectoryName(tmpFileName)); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)newRuntimeEnv.Host; // Using abs path tmpFileName ValidateResolveSourceFileNameSearchResult(host, tmpFileName); }
//[Ignore] public void TryGetSourceFile_WithEncodingAndKind() { // Setup test env string tmpFileName = TestHelpers.CreateTempSourceFile(_codeSnippets[CodeType.OneLineAssignmentStatement], ".py"); // Setup expected test vars string lookupVarName = "x"; object expectedResult = 3; ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)CreateTestHost(typeof(ScriptHostBasicSubTest), tmpFileName); // Verify results ValidateTryGetSourceFile(host, tmpFileName, lookupVarName, expectedResult); }
//[Ignore] // Bug see ResolveSourceFileName bug public void ResolveSourceFile_PassValidName() { // Get source string testSrc = _codeSnippets[CodeType.OneLineAssignmentStatement]; // Setup env for search. string tmpFileName = TestHelpers.CreateTempSourceFile(testSrc, ".py"); // This could possble enable the host to be aware of other search path ScriptRuntime newRuntimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), Path.GetDirectoryName(tmpFileName)); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)newRuntimeEnv.Host; ScriptScope scope = newRuntimeEnv.ExecuteFile(tmpFileName); // Using abs path tmpFileName ValidateResolveSourceFileSearchResult(host, tmpFileName, Path.GetDirectoryName(tmpFileName)); }
//[Ignore] public void SourceFileSearchPath_NullPathEnvironmentVariableName() { // Todo - Investigate this to verify correctness. // Setup derived With basic DerivedHostTest ScriptRuntime runtimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), "-nothing"); // Setup Env Var to null/empty TestHelpers.EnvSetupTearDown EnvTest = new TestHelpers.EnvSetupTearDown("DLRPATH", ""); // Setup host ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)runtimeEnv.Host; // Setup expected paths List <string> expectedPaths = new List <string> { "." }; // Verify results ValidateSourceFileSearchPathValues(host.GetSourceFileSearchPath(), expectedPaths); }
//[Ignore] // Bug # 475921 public void ResolveSourceFileName_LookForFilePysicallyAddFileAndDLRPATH() { // Adjust DLRPATH and place a file in this directory // After looking at the source code I see that I need to leave off the file extension. string fileExt = ".py"; string tmpFileName = TestHelpers.CreateTempSourceFile(_codeSnippets[CodeType.OneLineAssignmentStatement], fileExt); string FileNameInDLRPath = Path.GetFileName(tmpFileName).Replace(fileExt, ""); string testDLRPath = Path.GetDirectoryName(tmpFileName); TestHelpers.EnvSetupTearDown EnvTest = new TestHelpers.EnvSetupTearDown("DLRPATH", testDLRPath); // This could possble enable the host to be aware of other search path ScriptRuntime newRuntimeEnv = CreateHostRuntime(typeof(ScriptHostBasicSubTest), "-nothing"); ScriptHostBasicSubTest host = (ScriptHostBasicSubTest)newRuntimeEnv.Host; // Verify search result ValidateResolveSourceFileNameSearchResult(host, FileNameInDLRPath, testDLRPath + "\\" + FileNameInDLRPath + fileExt); }