diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 21:48:15 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 21:48:15 +0000 |
commit | f02c8040b4110a2202f744abaacb9b69b4b76b2a (patch) | |
tree | 900525d2784647d08f4ba4f8bf9b3201e1203a97 /tools/emacs | |
parent | 744809e71a44f758fd3c4acefa97c7a32c249a26 (diff) | |
download | chromium_src-f02c8040b4110a2202f744abaacb9b69b4b76b2a.zip chromium_src-f02c8040b4110a2202f744abaacb9b69b4b76b2a.tar.gz chromium_src-f02c8040b4110a2202f744abaacb9b69b4b76b2a.tar.bz2 |
emacs: conditionalize behavior based on the OS we're parsing
We don't want to run the (expensive) Windows path fixup regex
on the (verbose) Mac output.
Review URL: http://codereview.chromium.org/5774003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69055 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/emacs')
-rw-r--r-- | tools/emacs/trybot.el | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/tools/emacs/trybot.el b/tools/emacs/trybot.el index 84eccdc..784241d 100644 --- a/tools/emacs/trybot.el +++ b/tools/emacs/trybot.el @@ -40,42 +40,52 @@ (get-chrome-root)) nil)))) -(defun trybot-fixup () +(defun trybot-fixup-win () + "Fix up Windows-specific output." + + ; Fix Windows paths ("d:\...\src\"). + (save-excursion + (while (re-search-forward "\\(^.:\\\\.*\\\\src\\\\\\)\\(.*?\\)[(:]" nil t) + (replace-match "" nil t nil 1) + ; Line now looks like: + ; foo\bar\baz.cc error message here + ; We want to fixup backslashes in path into forward slashes, + ; without modifying the error message - by matching up to the + ; first colon above (which will be just beyond the end of the + ; filename) we can use the end of the match as a limit. + (subst-char-in-region (point) (match-end 0) ?\\ ?/) + ; See if we can correct the file name casing. + (let ((filename (buffer-substring (match-beginning 2) (match-end 2)))) + (if (and (not (file-exists-p filename)) + (setq filename (case-corrected-filename filename))) + (replace-match filename t t nil 2)))))) + +(defun trybot-fixup-maclin () + "Fix up Mac/Linux output." + (save-excursion + (while (re-search-forward "^/b/build/[^ ]*/src/" nil t) + (replace-match "")))) + +(defun trybot-fixup (type-hint) "Parse and fixup the contents of the current buffer as trybot output." + ; XXX is there something I should so so this stuff doesn't end up on the + ; undo stack? + ;; Fixup paths. (cd (get-chrome-root)) - ;; Fix up path references. - ; XXX is there something I should so so this stuff doesn't end up on the - ; undo stack? - (goto-char (point-min)) - ; Fix Windows paths ("d:\...\src\"). - (while (re-search-forward "\\(^.:\\\\.*\\\\src\\\\\\)\\(.*?\\)[(:]" nil t) - (replace-match "" nil t nil 1) - ; Line now looks like: - ; foo\bar\baz.cc error message here - ; We want to fixup backslashes in path into forward slashes, without - ; modifying the error message - by matching up to the first colon above - ; (which will be just beyond the end of the filename) we can use the end of - ; the match as a limit. - (subst-char-in-region (point) (match-end 0) ?\\ ?/) - ; See if we can correct the file name casing. - (let ((filename (buffer-substring (match-beginning 2) (match-end 2)))) - (if (and (not (file-exists-p filename)) - (setq filename (case-corrected-filename filename))) - (replace-match filename t t nil 2)))) - - ; Fix Linux/Mac paths ("/b/build/.../src/"). (goto-char (point-min)) - (while (re-search-forward "^/b/build/[^ ]*/src/" nil t) - (replace-match "")) - ;; Clean up and switch into compilation mode. - (goto-char (point-min)) + ;; Fix up path references. + (cond ((eq type-hint 'win) (trybot-fixup-win)) + ((eq type-hint 'mac) (trybot-fixup-maclin)) + ((eq type-hint 'linux) (trybot-fixup-maclin)) + (t (trybot-fixup-win) (trybot-fixup-maclin))) + (compilation-mode)) -(defun trybot-test (filename) +(defun trybot-test (type-hint filename) "Load the given test data filename and do the trybot parse on it." (switch-to-buffer (get-buffer-create "*trybot-test*")) @@ -85,20 +95,20 @@ (insert-file-contents (concat (get-chrome-root) "tools/emacs/" filename)) - (trybot-fixup))) + (trybot-fixup type-hint))) (defun trybot-test-win () "Load the Windows test data and do the trybot parse on it." (interactive) - (trybot-test "trybot-windows.txt")) + (trybot-test 'win "trybot-windows.txt")) (defun trybot-test-mac () "Load the Mac test data and do the trybot parse on it." (interactive) - (trybot-test "trybot-mac.txt")) + (trybot-test 'mac "trybot-mac.txt")) (defun trybot-test-linux () "Load the Linux test data and do the trybot parse on it." (interactive) - (trybot-test "trybot-linux.txt")) + (trybot-test 'linux "trybot-linux.txt")) (defun trybot (url) "Fetch a trybot URL and fix up the output into a compilation-mode buffer." @@ -115,10 +125,15 @@ ;; Extract the body out of the URL. ; TODO: delete HTTP headers somehow. (let ((inhibit-read-only t) - (coding-system-for-read 'utf-8-dos)) + (coding-system-for-read 'utf-8-dos) + (type-hint (cond ((string-match "/win/" url) 'win) + ((string-match "/mac/" url) 'mac) + ; Match /linux, /linux_view, etc. + ((string-match "/linux" url) 'linux) + (t 'unknown)))) (switch-to-buffer (get-buffer-create "*trybot*")) (buffer-swap-text (url-retrieve-synchronously url)) - (trybot-fixup))) + (trybot-fixup type-hint))) (provide 'trybot) |