public ReactiveScriptReader(string path, Func<PluginLocator> locator, Action<string> dispatch) { _keyPath = path; _dispatch = dispatch; var profiles = new ProfileLocator(_keyPath); _localScriptsPathDefault = getPath(profiles.GetLocalProfilePath("default")); _localScriptsPath = getPath(profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile())); _globalScriptsPathDefault = getPath(profiles.GetGlobalProfilePath("default")); _globalScriptsPath = getPath(profiles.GetGlobalProfilePath(profiles.GetActiveGlobalProfile())); _pluginLocator = locator; }
public void Start( string path, ICacheBuilder cache, ICrawlResult crawlReader, PluginLocator pluginLocator, EventEndpoint eventDispatcher, string[] ignoreDirectories) { _cache = cache; _crawlReader = crawlReader; _eventDispatcher = eventDispatcher; Logger.Write("Setting up file trackers"); Logger.Write("Setting up token file trackers"); _tracker = new FileChangeTracker((x) => { if (x.Path.StartsWith(Path.Combine(path, ".OpenIDE"))) return; _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up local file trackers"); _localTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up global file trackers"); _globalTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Adding plugins to cache"); var plugins = pluginLocator.Locate().ToList(); foreach (var x in plugins) { var plugin = new PluginPattern(x); _plugins.Add(plugin); _cache.Plugins.Add( new CachedPlugin(x.GetLanguage(), plugin.Patterns)); Logger.Write("Added plugin " + x.GetLanguage()); } var locator = new ProfileLocator(path); var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile()); if (Directory.Exists(profilePath)) { Logger.Write("Starting tracker for {0}", path); _tracker.Start(path, getFilter(), handleChanges, ignoreDirectories); } else { Logger.Write("No local configuration point so not starting file tracker"); } if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { if (Directory.Exists(profilePath)) { Logger.Write("Starting tracker for {0}", profilePath); _localTracker.Start(profilePath, getFilter(), handleChanges, ignoreDirectories); } } var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile()); if (Directory.Exists(globalPath)) { Logger.Write("Starting tracker for {0}", globalPath); _globalTracker.Start(globalPath, getFilter(), handleChanges, ignoreDirectories); } }
private string getInstallPath(Package package, ProfileLocator profiles, string activeProfile) { string installPath; if (package.Target.StartsWith("language-")) { var path = getLanguageInstallPath(package, !_useGlobal); if (path == null) { _dispatch("error|could not find language to install language dependent package in"); return null; } if (_useGlobal && !profiles.IsGlobal(path)) { _dispatch("error|cannot install language dependent package globally as language is installed locally."); return null; } return path; } if (_useGlobal) installPath = profiles.GetGlobalProfilePath(activeProfile); else installPath = profiles.GetLocalProfilePath(activeProfile); if (installPath == null) { _dispatch("error|the current location does not have an initialized config point"); return null; } return Path.Combine(installPath, package.Target + "s"); }
public void Execute(string[] arguments) { _verbose = arguments.Contains("-v"); _showoutputs = arguments.Contains("-o"); _showevents = arguments.Contains("-e"); _printOnlyErrorsAndInconclusives = arguments.Contains("--only-errors"); _logging = arguments.Contains("-l"); var profiles = new ProfileLocator(_token); var testFiles = new List<string>(); if (arguments.Length > 0 && File.Exists(arguments[0])) { testFiles.Add(arguments[0]); } else { testFiles .AddRange( getTests(profiles.GetLocalProfilePath("default"))); testFiles .AddRange( getTests(profiles.GetGlobalProfilePath("default"))); testFiles .AddRange( getTests( Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location))); } foreach (var testFile in testFiles) { _testRunLocation = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString()); Console.WriteLine("Testing: {0}", testFile); var eventListenerStarted = false; var systemStarted = false; var runCompleted = false; var eventListener = new Thread(() => { var eventSocketClient = new EventStuff.EventClient( (line) => { if (line == "codeengine started") { log("Code engine started"); systemStarted = true; } if (line == "codeengine stopped") { log("Code engine stopped"); runCompleted = true; } _events.Add(line); }); while (true) { eventSocketClient.Connect(_testRunLocation); eventListenerStarted = true; if (!eventSocketClient.IsConnected) { Thread.Sleep(10); if (runCompleted || systemStarted) break; continue; } log("Event listener connected"); while (eventSocketClient.IsConnected) Thread.Sleep(10); break; } eventListenerStarted = false; }); var isQuerying = false; var useEditor = false; var tests = new List<string>(); Process proc = null; try { Directory.CreateDirectory(_testRunLocation); _events = new List<string>(); _outputs = new List<string>(); _asserts = new List<string>(); log("Initializing test location"); runCommand("init"); // Make sure we run tests in default profile is // this by any chance overloaded in init command runCommand("profile load default"); eventListener.Start(); new Thread(() => { log("Starting test process"); var testProc = new Process(); try { testProc .Query( testFile, _testRunLocation, false, Environment.CurrentDirectory, (error, line) => { if (line == "initialized" || line.StartsWith("initialized|")) { log("Test file initialized"); proc = testProc; var chunks = line.Split(new[] {'|'}); if (chunks.Length > 1 && chunks[1] == "editor") { while (!eventListenerStarted) Thread.Sleep(10); log("Starting editor"); new Process().Run("oi", "editor test", false, _testRunLocation); log("Editor launched"); useEditor = true; } else { log("System started"); systemStarted = true; } return; } if (line == "end-of-conversation") { isQuerying = false; return; } handleFeedback(proc, error, line); }); } catch (Exception ex) { handleFeedback(testProc, true, "A fatal error occured while running " + testFile + Environment.NewLine + ex.Message); } isQuerying = false; runCompleted = true; }).Start(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } log("Waiting for system to complete loading"); while (!systemStarted) Thread.Sleep(10); log("Getting tests"); isQuerying = ask(proc, "get-tests"); while (isQuerying) Thread.Sleep(10); tests.AddRange( _summary.ToString() .Replace("\t", "") .Split( new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)); foreach (var test in tests) { if (_currentTest != null) writeInconclusive(); log("Running test: " + test); _outputs.Clear(); _events.Clear(); _asserts.Clear(); _currentTest = test; _summary = new StringBuilder(); if (_verbose) Console.Write(_currentTest + "..."); isQuerying = ask(proc, "test|" + _currentTest); while (isQuerying) Thread.Sleep(10); } if (useEditor) { log("Shuting down editor"); new Process().Run("oi", "editor command kill", false, _testRunLocation); } log("Shuting down system"); ask(proc, "shutdown"); while (!runCompleted) Thread.Sleep(10); log("Waiting for event listener to stop"); while (eventListenerStarted) Thread.Sleep(10); if (Directory.Exists(_testRunLocation)) Directory.Delete(_testRunLocation, true); if (_currentTest != null) writeInconclusive(); _currentTest = null; log("Test run finished"); Console.WriteLine(); } }
private List<string> getLanguagePaths() { var orderedProfilePaths = new List<string>(); var profiles = new ProfileLocator(_keyPath); var profilePath = profiles.GetGlobalProfilePath("default"); if (profilePath != null) orderedProfilePaths.Add(Path.Combine(profilePath, "languages")); profilePath = profiles.GetGlobalProfilePath(profiles.GetActiveGlobalProfile()); if (profilePath != null) orderedProfilePaths.Add(Path.Combine(profilePath, "languages")); profilePath = profiles.GetLocalProfilePath("default"); if (profilePath != null) orderedProfilePaths.Add(Path.Combine(profilePath, "languages")); profilePath = profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile()); if (profilePath != null) orderedProfilePaths.Add(Path.Combine(profilePath, "languages")); var paths = new List<string>(); foreach (var plugin in _pluginLocator().Locate()) addLanguagePath(plugin, orderedProfilePaths, ref paths); paths.Reverse(); return paths; }
private string getInstallPath(Package package, ProfileLocator profiles, string activeProfile) { string installPath; if (package.Target.StartsWith("language-")) return getLanguageInstallPath(package); if (_useGlobal) installPath = profiles.GetGlobalProfilePath(activeProfile); else installPath = profiles.GetLocalProfilePath(activeProfile); if (installPath == null) return null; return Path.Combine(installPath, package.Target + "s"); }
public string GetGlobalPath(string profile) { var locator = new ProfileLocator(_keyPath); return getPath(locator.GetGlobalProfilePath(profile)); }
private void listProfilesRaw() { var profileLocator = new ProfileLocator(Environment.CurrentDirectory); Console.WriteLine("active-global|" + profileLocator.GetActiveGlobalProfile()+"|"+profileLocator.GetGlobalProfilePath(profileLocator.GetActiveGlobalProfile())); Console.WriteLine("active-local|" + profileLocator.GetActiveLocalProfile()+"|"+profileLocator.GetLocalProfilePath(profileLocator.GetActiveLocalProfile())); var globalProfiles = profileLocator.GetProfilesForPath( profileLocator.GetGlobalProfilesRoot()); globalProfiles.Insert(0, "default"); globalProfiles.ForEach(x => Console.WriteLine("global|"+x+"|"+profileLocator.GetGlobalProfilePath(x))); if (Directory.Exists(profileLocator.GetLocalProfilesRoot())) { var localProfiles = profileLocator.GetProfilesForPath( profileLocator.GetLocalProfilesRoot()); localProfiles.Insert(0, "default"); localProfiles.ForEach(x => Console.WriteLine("local|"+x+"|"+profileLocator.GetLocalProfilePath(x))); } }
private string getProfilePath(Args args, string name) { var profileLocator = new ProfileLocator(Environment.CurrentDirectory); if (args.IsGlobal) return profileLocator.GetGlobalProfilePath(name); else return profileLocator.GetLocalProfilePath(name); }