当前位置: 首页>>代码示例>>C#>>正文


C# Options.MakeAbsolute方法代码示例

本文整理汇总了C#中Tests.Options.MakeAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C# Options.MakeAbsolute方法的具体用法?C# Options.MakeAbsolute怎么用?C# Options.MakeAbsolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tests.Options的用法示例。


在下文中一共展示了Options.MakeAbsolute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Rewrite

    internal static string Rewrite(string absoluteSourceDir, string absoluteBinary, Options options)
    {
      var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
      var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
      var absoluteSourcedir = Path.GetDirectoryName(absoluteBinary);
      var absoluteSource = absoluteBinary;
      var libPathsString = FormLibPaths(absoluteSourceDir, contractreferencedir, options);

      var targetName = options.TestName + ".rw" + Path.GetExtension(absoluteBinary);
      var binDir = options.UseBinDir ? Path.Combine(Path.Combine(absoluteSourcedir, "bin"), options.BuildFramework) : absoluteSourcedir;
      var targetfile = Path.Combine(binDir, targetName);
      Console.WriteLine("Rewriting '{0}' to '{1}'", absoluteBinary, targetfile);
      if (!Directory.Exists(binDir))
      {
        Directory.CreateDirectory(binDir);
      }
      var exitCode = RunProcess(binDir, options.MakeAbsolute(FoxtrotExe),
        String.Format("/out:{0} -nobox -libpaths:{3} -libpaths:{4} {5} {1} {2}", targetfile, options.FoxtrotOptions, absoluteSource, referencedir, contractreferencedir, libPathsString),
        options.TestName);
      if (exitCode != 0)
      {
        return null;
      }
      else
      {
        if (options.UseBinDir)
        {
          File.Copy(targetfile, Path.Combine(absoluteSourcedir, targetName), true);
          return Path.Combine(absoluteSourcedir, targetName);
        }
      }
      return targetfile;
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:33,代码来源:TestDriver.cs

示例2: Rewrite

    internal static object Rewrite(string absoluteSourceDir, string absoluteBinary, Options options, bool alwaysCapture = false)
    {
      string referencedir;
      if (Path.IsPathRooted(options.ReferencesFramework))
      {
        referencedir = options.ReferencesFramework;
      }
      else
      {
        referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.ReferencesFramework));
      }
      var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
      var absoluteSourcedir = Path.GetDirectoryName(absoluteBinary);
      var absoluteSource = absoluteBinary;
      var libPathsString = FormLibPaths(absoluteSourceDir, contractreferencedir, options);

      var targetName = options.TestName + ".rw" + Path.GetExtension(absoluteBinary);
      var binDir = options.UseBinDir ? Path.Combine(Path.Combine(absoluteSourcedir, "bin"), options.BuildFramework) : absoluteSourcedir;
      var targetfile = Path.Combine(binDir, targetName);
      Console.WriteLine("Rewriting '{0}' to '{1}'", absoluteBinary, targetfile);
      if (!Directory.Exists(binDir))
      {
        Directory.CreateDirectory(binDir);
      }
      var optionString = String.Format("/out:{0} -nobox -libpaths:{3} {4} {1} {2}", targetfile, options.FoxtrotOptions, absoluteSource, referencedir, libPathsString);
      if (absoluteBinary.EndsWith("mscorlib.dll"))
        optionString = String.Format("/platform:{0} {1}", absoluteBinary, optionString);
      var capture = RunProcessAndCapture(binDir, options.GetFullExecutablePath(FoxtrotExe), optionString, options.TestName);
      if (capture.ExitCode != 0)
      {
        if (options.MustSucceed)
        {
          Assert.AreEqual(0, capture.ExitCode, "{0} returned an errorcode of {1}.", FoxtrotExe, capture.ExitCode);
        }
        return capture;
      }
      else
      {
        if (alwaysCapture) return capture;

        if (options.UseBinDir)
        {
          var fileName = Path.Combine(absoluteSourcedir, targetName);
          if (File.Exists(fileName))
          {
            try
            {
              File.SetAttributes(fileName, FileAttributes.Normal);
            }
            catch { }
          }
          File.Copy(targetfile, fileName, true);
          return fileName;
        }
      }
      return targetfile;
    }
开发者ID:gitter-badger,项目名称:CodeContracts,代码行数:57,代码来源:TestDriver.cs

示例3: PEVerify

    internal static int PEVerify(string assemblyFile, Options options)
    {
      var peVerifyPath = options.MakeAbsolute(Path.Combine(ToolsRoot, String.Format(@"{0}\peverify.exe", options.BuildFramework)));
      assemblyFile = options.MakeAbsolute(assemblyFile);
      var path = Path.GetDirectoryName(assemblyFile);
      var file = Path.GetFileName(assemblyFile);
      if (file == "mscorlib.dll") return -1; // peverify returns 0 for mscorlib without verifying.

      var exitCode = RunProcess(path, peVerifyPath, "/unique \"" + file + "\"", "repro");
      return exitCode;
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:11,代码来源:TestDriver.cs

示例4: RewriteAndVerify

 internal static string RewriteAndVerify(string sourceDir, string binary, Options options)
 {
   if (!Path.IsPathRooted(sourceDir)) { sourceDir = options.MakeAbsolute(sourceDir); }
   if (!Path.IsPathRooted(binary)) { binary = options.MakeAbsolute(binary); }
   string target = Rewrite(sourceDir, binary, options);
   if (target != null)
   {
     PEVerify(target, options);
   }
   return target;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:11,代码来源:TestDriver.cs

示例5: Clousot1Slicing

 internal static void Clousot1Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
 {
     var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
     var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
     var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
     var absoluteSource = absoluteBinary;
     var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
     var args = String.Format("{0} -cci1 /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
     if (options.Fast || System.Diagnostics.Debugger.IsAttached)
     {
         output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
         // Use output to avoid Clousot from closing the Console
         Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
     }
     else
         RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
 }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:17,代码来源:TestDriver.cs

示例6: Clousot

        internal static void Clousot(string absoluteSourceDir, string absoluteBinary, Options options, string testName, int testindex, Output output)
        {
            var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
            var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
            var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
            var absoluteSource = absoluteBinary;
            var libPathsString = FormLibPaths(contractreferencedir, options);
            var args = string.Format("{0} /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);

            WriteRSPFile(absoluteBinaryDir, testName, args);
            
            if (options.Fast || Debugger.IsAttached)
            {
                output.WriteLine("Calling CCI1Driver.Main with: {0}", args);
                // Use output to avoid Clousot from closing the Console
                Assert.Equal(0, Microsoft.Research.CodeAnalysis.CCI1Driver.Main(args.Split(' '), output));
            }
            else
            {
                RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(ClousotExe), args, output, testName);
            }
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:22,代码来源:TestDriver.cs

示例7: Build

        internal static string Build(Options options, out string absoluteSourceDir)
        {
            var sourceFile = options.MakeAbsolute(options.SourceFile);

            var compilerPath = options.GetCompilerAbsolutePath(ToolsRoot);
            Assert.IsTrue(File.Exists(compilerPath), string.Format("Can't find compiler at '{0}'", compilerPath));

            var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ReferencesFramework));
            var sourcedir = absoluteSourceDir = Path.GetDirectoryName(sourceFile);

            var outputdir = Path.Combine(Path.Combine(sourcedir, "bin"), options.CompilerPath);
            var extension = options.UseExe ? ".exe" : ".dll";
            var targetKind = options.UseExe ? "exe" : "library";

            var targetfile = Path.Combine(outputdir, options.TestName + extension);

            // add Microsoft.Contracts reference if needed
            if (options.IsV35)
            {
                options.References.Add("Microsoft.Contracts.dll");
            }

            var oldCwd = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = sourcedir;

                var resolvedReferences = ResolveReferences(options);
                var referenceString = ReferenceOptions(resolvedReferences);

                if (!Directory.Exists(outputdir))
                {
                    Directory.CreateDirectory(outputdir);
                }

                string arguments = String.Format("/t:{4} /out:{0} {3} {2} {1}", targetfile, sourceFile, referenceString, options.FinalCompilerOptions, targetKind);

                if (!options.ReleaseMode)
                {
                    arguments = "/debug " + arguments;
                }

                var exitCode = RunProcess(sourcedir, compilerPath, arguments, true);

                if (exitCode != 0)
                {
                    return null;
                }

                // add reference to Microsoft.Contracts.dll if not already done because of transitive closure issues
                if (!options.References.Contains("Microsoft.Contracts.dll"))
                {
                    options.References.Add("Microsoft.Contracts.dll");

                    // recompute resolvedReferences
                    resolvedReferences = ResolveReferences(options);
                }

                CopyReferenceAssemblies(resolvedReferences, outputdir);

                return targetfile;
            }
            finally
            {
                Environment.CurrentDirectory = oldCwd;
            }
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:68,代码来源:TestDriver.cs

示例8: StartService

        private static void StartService(Options options)
        {
            if (serviceProcess != null)
                StopService();

            // First make sure another instance is not already running (because we don't know which version is running)
            foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClousotServiceHostExe)))
            {
                process.CloseMainWindow();
                if (!process.WaitForExit(1000))
                    process.Kill();
            }

            var serviceHostDir = options.MakeAbsolute(Path.GetDirectoryName(ClousotServiceHostExe));

            // note: we do not want to use ClousotServiceHostExe from the deployment directory because the app.config will be missing
            serviceProcess = StartServiceProcess(serviceHostDir, options.MakeAbsolute(ClousotServiceHostExe), "", Output.Ignore);
        }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:18,代码来源:TestDriver.cs

示例9: ResolveReferences

        private static List<string> ResolveReferences(Options options)
        {
            var result = new List<string>();
            foreach (var r in options.References)
            {
                foreach (var root in options.LibPaths)
                {
                    var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));

                    var path = Path.Combine(dir, r);
                    if (File.Exists(path))
                    {
                        result.Add(path);
                        break;
                    }
                }
                foreach (var root in new[] { ReferenceDirRoot, ContractReferenceDirRoot })
                {
                    var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));

                    var path = Path.Combine(dir, r);
                    if (File.Exists(path))
                    {
                        result.Add(path);
                        break;
                    }
                }
            }
            return result;
        }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:30,代码来源:TestDriver.cs

示例10: Build

        internal static string Build(Options options, string extraCompilerOptions, Output output, out string absoluteSourceDir)
        {
            var sourceFile = options.MakeAbsolute(options.SourceFile);
            var compilerpath = options.MakeAbsolute(Path.Combine(ToolsRoot, options.BuildFramework, options.Compiler));
            var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.BuildFramework));
            var sourcedir = absoluteSourceDir = Path.GetDirectoryName(sourceFile);
            var outputdir = Path.Combine(sourcedir, "bin", options.BuildFramework);
            var extension = options.UseExe ? ".exe" : ".dll";
            var targetKind = options.UseExe ? "exe" : "library";
            var suffix = "_" + options.TestInstance;
            if (options.GenerateUniqueOutputName)
                suffix += "." + randGenerator.Next(0x10000).ToString("X4"); // enables concurrent tests on the same source file
            var targetfile = Path.Combine(outputdir, Path.GetFileNameWithoutExtension(sourceFile) + suffix + extension);
            // add Microsoft.Contracts reference if needed
            if (!options.BuildFramework.Contains("v4."))
            {
                options.References.Add("Microsoft.Contracts.dll");
            }

            // MB: do not modify the CurrentDirectory, that could cause parallel tests to fail

            var resolvedReferences = ResolveReferences(options);
            var referenceString = ReferenceOptions(resolvedReferences);
            if (!Directory.Exists(outputdir))
            {
                Directory.CreateDirectory(outputdir);
            }
            var args = String.Format("/debug /t:{4} /out:{0} {5} {3} {2} {1}", targetfile, sourceFile, referenceString, options.CompilerOptions(resolvedReferences), targetKind, extraCompilerOptions);
            var exitCode = RunProcess(sourcedir, compilerpath, args, output);
            if (exitCode != 0)
            {
                return null;
            }
            //CopyReferenceAssemblies(resolvedReferences, outputdir);

            return targetfile;
        }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:37,代码来源:TestDriver.cs

示例11: FormLibPaths

        private static string FormLibPaths(string contractReferenceDir, Options options)
        {
            // MB: do not change CurrentDirectory because it makes parallel tests fail

            if (options.LibPaths == null)
                return "";

            StringBuilder sb = null;
            if (options.UseContractReferenceAssemblies)
                sb = new StringBuilder("/libpaths:").Append(contractReferenceDir);

            foreach (var path in options.LibPaths)
            {
                if (sb == null)
                    sb = new StringBuilder("/libpaths:");
                else
                    sb.Append(';');

                sb.Append(options.MakeAbsolute(Path.Combine(path, options.ContractFramework)));
            }
            if (sb == null)
                return "";
            return sb.ToString();
        }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:24,代码来源:TestDriver.cs

示例12: RewriteBinary

 internal static void RewriteBinary(Options options, string sourceDir)
 {
     var absoluteDir = options.MakeAbsolute(sourceDir);
     var binary = Path.Combine(absoluteDir, options.SourceFile);
     Rewrite(absoluteDir, binary, options);
 }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:6,代码来源:TestDriver.cs

示例13: CompareExpectedOutput

        private static void CompareExpectedOutput(Options options, OutputCapture capture)
        {
            var expected = File.ReadAllLines(options.MakeAbsolute(@"Foxtrot\Tests\CheckerTests\" + Path.GetFileNameWithoutExtension(options.SourceFile) + ".Expected"));
            var expectedIndex = 0;
            var absoluteFile = options.MakeAbsolute(options.SourceFile);
            for (int i = 0; i < capture.stdOut.Count; i++)
            {
                var actual = capture.stdOut[i];

                if (actual.StartsWith("Trace:")) continue;
                if (actual.StartsWith("elapsed time:")) continue;
                if (expectedIndex >= expected.Length)
                {
                    Assert.AreEqual(null, actual);
                }
                var expectedLine = expected[expectedIndex++];

                if (actual.StartsWith(absoluteFile, StringComparison.InvariantCultureIgnoreCase))
                {
                    actual = TrimFilePath(actual, options.SourceFile);
                    expectedLine = TrimFilePath(expectedLine, options.SourceFile);
                }
                Assert.AreEqual(expectedLine, actual);
            }
            if (expectedIndex < expected.Length)
            {
                Assert.AreEqual(expected[expectedIndex], null);
            }
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:29,代码来源:TestDriver.cs

示例14: RewriteFrameworkDlls40

 public void RewriteFrameworkDlls40()
 {
   var options = new Options(this.TestContext);
   var framework = @".NetFramework\v4.0";
   options.ContractFramework = framework;
   var dllpath = FrameworkBinariesToRewritePath + framework;
   options.BuildFramework = options.MakeAbsolute(dllpath);
   var extrareferencedir = options.MakeAbsolute(TestDriver.ReferenceDirRoot);
   options.LibPaths.Add(extrareferencedir);
   options.FoxtrotOptions = options.FoxtrotOptions + " /verbose:4";
   options.UseContractReferenceAssemblies = false;
   if (File.Exists(options.MakeAbsolute(Path.Combine(dllpath, options.SourceFile))))
   {
     TestDriver.RewriteBinary(options, dllpath);
   }
 }
开发者ID:gitter-badger,项目名称:CodeContracts,代码行数:16,代码来源:RewriterTests.cs

示例15: FormLibPaths

        static string FormLibPaths(string absoluteSourceDir, string contractReferenceDir, Options options)
        {
            var oldcwd = Environment.CurrentDirectory;
            try
            {
                Environment.CurrentDirectory = absoluteSourceDir;

                StringBuilder sb = null;
                if (options.UseContractReferenceAssemblies)
                {
                    sb = new StringBuilder("/libpaths:").Append(contractReferenceDir);
                }
                if (options.LibPaths == null) return "";
                foreach (var path in options.LibPaths)
                {
                    if (sb == null)
                    {
                        sb = new StringBuilder("/libpaths:");
                    }
                    else
                    {
                        sb.Append(';');
                    }
                    sb.Append(options.MakeAbsolute(Path.Combine(path, options.ContractFramework)));
                }
                if (sb == null) return "";
                return sb.ToString();
            }
            finally
            {
                Environment.CurrentDirectory = oldcwd;
            }
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:33,代码来源:TestDriver.cs


注:本文中的Tests.Options.MakeAbsolute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。