public void OneTimeSetup() { GitHub.Unity.Guard.InUnitTestRunner = true; LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log")); //LogHelper.TracingEnabled = true; TaskManager = new TaskManager(); var syncContext = new ThreadSynchronizationContext(Token); TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext); var env = new DefaultEnvironment(new CacheContainer()); TestBasePath = NPath.CreateTempDirectory("integration tests"); env.FileSystem.SetCurrentDirectory(TestBasePath); env.Initialize("5.6", TestBasePath, TestBasePath, TestBasePath, TestBasePath.Combine("Assets")); var repo = Substitute.For <IRepository>(); repo.LocalPath.Returns(TestBasePath); env.Repository = repo; var platform = new Platform(env); ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token); var processEnv = platform.GitEnvironment; var installer = new GitInstaller(env, ProcessManager, TaskManager.Token); var state = installer.FindSystemGit(new GitInstaller.GitInstallationState()); env.GitInstallationState = state; }
public void OneTimeSetup() { GitHub.Unity.Guard.InUnitTestRunner = true; LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log")); //LogHelper.TracingEnabled = true; TaskManager = new TaskManager(); var syncContext = new ThreadSynchronizationContext(Token); TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext); var env = new DefaultEnvironment(); TestBasePath = NPath.CreateTempDirectory("integration-tests"); env.FileSystem.SetCurrentDirectory(TestBasePath); var repo = Substitute.For <IRepository>(); repo.LocalPath.Returns(TestBasePath); env.Repository = repo; var platform = new Platform(env); ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token); var processEnv = platform.GitEnvironment; var path = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor()) .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git") .Start().Result; env.GitExecutablePath = path.IsInitialized ? path : "git".ToNPath(); }
public void OneTimeSetup() { Logging.LogAdapter = new ConsoleLogAdapter(); //Logging.TracingEnabled = true; TaskManager = new TaskManager(); var syncContext = new ThreadSynchronizationContext(Token); TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext); var env = new DefaultEnvironment(); TestBasePath = NPath.CreateTempDirectory("integration-tests"); env.FileSystem.SetCurrentDirectory(TestBasePath); var repo = Substitute.For <IRepository>(); repo.LocalPath.Returns(TestBasePath); env.Repository = repo; var platform = new Platform(env); ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token); var processEnv = platform.GitEnvironment; var path = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor()) .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git") .Start().Result; env.GitExecutablePath = path ?? "git".ToNPath(); }
public void Setup() { NPath.FileSystem = new FileSystem(); _tempPath = NPath.CreateTempDirectory("NiceIOTest"); NPath.FileSystem.SetCurrentDirectory(_tempPath); NPath.FileSystem.SetProcessDirectory(_tempPath); }
public void Test() { var path = NPath.CreateTempDirectory("myprefix"); Assert.IsTrue(Directory.Exists(path.ToString())); Assert.IsFalse(path.IsRelative); StringAssert.Contains("myprefix", path.ToString()); }
public async Task InstallGit() { var environmentPath = NPath.CreateTempDirectory("integration-test-environment"); var environment = await Initialize(TestRepoMasterDirtyUnsynchronized, environmentPath); var gitSetup = new GitInstaller(environment, TaskManager.Token); var expectedPath = gitSetup.GitInstallationPath; var setupDone = false; var percent = -1f; gitSetup.GitExecutablePath.FileExists().Should().BeFalse(); setupDone = await gitSetup.SetupIfNeeded(new Progress <float>(x => percent = x)); if (environment.IsWindows) { environment.GitExecutablePath = gitSetup.GitExecutablePath; setupDone.Should().BeTrue(); percent.Should().Be(1); Logger.Trace("Expected GitExecutablePath: {0}", gitSetup.GitExecutablePath); gitSetup.GitExecutablePath.FileExists().Should().BeTrue(); var gitLfsDestinationPath = gitSetup.GitInstallationPath; gitLfsDestinationPath = gitLfsDestinationPath.Combine("mingw32"); gitLfsDestinationPath = gitLfsDestinationPath.Combine("libexec", "git-core", "git-lfs.exe"); gitLfsDestinationPath.FileExists().Should().BeTrue(); var calculateMd5 = NPath.FileSystem.CalculateMD5(gitLfsDestinationPath); Assert.IsTrue(string.Compare(calculateMd5, GitInstaller.WindowsGitLfsExecutableMD5, true) == 0); setupDone = await gitSetup.SetupIfNeeded(new Progress <float>(x => percent = x)); setupDone.Should().BeFalse(); } else { environment.GitExecutablePath = "/usr/local/bin/git".ToNPath(); setupDone.Should().BeFalse(); } var platform = new Platform(environment); var gitEnvironment = platform.GitEnvironment; var processManager = new ProcessManager(environment, gitEnvironment, TaskManager.Token); List <GitBranch> gitBranches = null; gitBranches = await processManager .GetGitBranches(TestRepoMasterDirtyUnsynchronized, environment.GitExecutablePath) .StartAsAsync(); gitBranches.Should().BeEquivalentTo( new GitBranch("master", "origin/master: behind 1", true), new GitBranch("feature/document", "origin/feature/document", false)); }
protected IntegrationTestEnvironment CreateCleanEnvironment(ICacheContainer container, NPath repoPath, bool enableEnvironmentTrace = false) { return(new IntegrationTestEnvironment(container, repoPath, SolutionDirectory, new CreateEnvironmentOptions(NPath.CreateTempDirectory("gfu")), enableEnvironmentTrace, false)); }
public virtual void OnSetup() { TestBasePath = NPath.CreateTempDirectory("integration tests"); NPath.FileSystem.SetCurrentDirectory(TestBasePath); TestRepoMasterCleanUnsynchronized = TestBasePath.Combine("IOTestsRepo", "IOTestsRepo_master_clean_unsync"); TestRepoMasterCleanUnsynchronizedRussianLanguage = TestBasePath.Combine("IOTestsRepo", "IOTestsRepo_master_clean_sync_with_russian_language"); TestRepoMasterCleanSynchronized = TestBasePath.Combine("IOTestsRepo", "IOTestsRepo_master_clean_sync"); TestRepoMasterDirtyUnsynchronized = TestBasePath.Combine("IOTestsRepo", "IOTestsRepo_master_dirty_unsync"); TestRepoMasterTwoRemotes = TestBasePath.Combine("IOTestsRepo", "IOTestsRepo_master_two_remotes"); InitializeTaskManager(); }
public static NPath Compile(List <SourceFileDescription> program, IEnumerable <NPath> additionalLibs, NPath outputFile = null) { var executable = outputFile ?? NPath.CreateTempDirectory("CSharp").Combine("program.exe"); var tmpDir = executable.Parent; foreach (var fileEntry in program) { var file = tmpDir.Combine(fileEntry.File).WriteAllText(fileEntry.Contents); //Console.WriteLine(".cs: " + file); } var csproj = tmpDir.Combine("program.csproj"); csproj.WriteAllText(CSProjContentsFor(program, additionalLibs)); Console.WriteLine("csproj: " + csproj); var compiler = new NPath(@"C:\il2cpp-dependencies\MonoBleedingEdge\builds\monodistribution\bin\mcs" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".bat" : "")); if (additionalLibs == null) { additionalLibs = new NPath[0]; } var rsp = tmpDir.Combine("args.rsp"); rsp.WriteAllText(program.Select(f => f.File).InQuotes().SeperateWithSpace()); var args = new Shell.ExecuteArgs() { Executable = compiler.ToString(), Arguments = "@" + rsp + " " + additionalLibs.InQuotes().Select(l => "-r:" + l).SeperateWithSpace() + " -debug -langversion:6 -out:" + executable.InQuotes(), WorkingDirectory = tmpDir.ToString() }; Console.WriteLine(args.Arguments); var executeResult = Shell.Execute(args); Console.Write(executeResult.StdErr + executeResult.StdOut); if (executeResult.ExitCode != 0) { throw new Exception(); } foreach (var lib in additionalLibs) { lib.Copy(tmpDir); } return(executable); }
public void VerifyMacGitLfsBundle() { var environmentPath = NPath.CreateTempDirectory("integration-test-environment"); var gitLfsPath = environmentPath.Combine("git-lfs"); gitLfsPath.Exists().Should().BeFalse(); var inputZipFile = SolutionDirectory.Combine("PlatformResources", "mac", "git-lfs.zip"); var fastZip = new FastZip(); fastZip.ExtractZip(inputZipFile, environmentPath, null); gitLfsPath.Exists().Should().BeTrue(); var calculateMd5 = NPath.FileSystem.CalculateMD5(gitLfsPath); calculateMd5.ToLower().Should().Be(GitInstaller.MacGitLfsExecutableMD5.ToLower()); }
public void VerifyGitLfsBundle() { var environmentPath = NPath.CreateTempDirectory("integration-test-environment"); var gitLfsPath = environmentPath.Combine("git-lfs.exe"); gitLfsPath.Exists().Should().BeFalse(); var inputZipFile = SolutionDirectory.Combine("PlatformResources", "windows", "git-lfs.zip"); var fastZip = new FastZip(); fastZip.ExtractZip(inputZipFile, environmentPath, null); gitLfsPath.Exists().Should().BeTrue(); var calculateMd5 = NPath.FileSystem.CalculateMD5(gitLfsPath); Assert.IsTrue(string.Compare(calculateMd5, GitInstaller.WindowsGitLfsExecutableMD5, true) == 0); }
public string[] Run(JamRunnerInstructions instructions) { var tempDir = NPath.CreateTempDirectory("jamrunner"); instructions.WorkingDir = instructions.WorkingDir ?? tempDir; foreach (var f in instructions.JamfilesToCreate) { instructions.WorkingDir.Combine(f.File).WriteAllText(f.Contents); } string startupArg = ""; if (instructions.CSharpFiles.Any()) { var csharpExe = tempDir.Combine("csharp.exe"); CSharpRunner.Compile(instructions.CSharpFiles, JamToCSharpConverter.RuntimeDependencies, csharpExe); startupArg += "-m " + csharpExe.InQuotes(); } var jamPath = Environment.OSVersion.Platform == PlatformID.Win32NT ? "external/jamplus/bin/win32/jam.exe" : "external/jamplus/macosx64/jam"; var jamBinary = ConverterRoot.Combine(jamPath); startupArg += " -f " + (instructions.JamFileToInvokeOnStartup ?? instructions.JamfilesToCreate[0].File.FileName); startupArg += " -C " + instructions.WorkingDir; startupArg += " " + instructions.AdditionalArg; Console.WriteLine("args: " + startupArg); var execute = Shell.Execute(jamBinary, startupArg); var lines = execute.Split(new[] { Environment.NewLine }, StringSplitOptions.None); var relevance = RelevantLinesFrom(lines); return(relevance.ToArray()); }
public void Setup() { _tempPath = NPath.CreateTempDirectory("NiceIOTest"); }
public virtual void OnSetup() { TestBasePath = NPath.CreateTempDirectory("integration-tests"); NPath.FileSystem.SetCurrentDirectory(TestBasePath); }
public TempDir(string prefix) { _path = NPath.CreateTempDirectory(prefix); }