aemoncannon / flyparse-mode

An emacs minor mode for parsing programming languages.

This URL has Read+Write access

flyparse-mode / test_helper.rb
100644 43 lines (40 sloc) 1.373 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright (c) 2007 Aemon Cannon, aemoncannon -at- gmail -dot- com
#
# This file is part of flyparse-mode
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
require 'find'
require 'rubygems'
require 'platform'
require 'popen4'
 
def run_tests(dir, testp, cmd_func, ignore_error = nil)
  Find.find(dir) { | path |
    if testp[path]
      puts "\n********* #{path} ***********"
      status = POpen4::popen4(cmd_func[path]) { | stdout, stderr, stdin, pid |
        stdout.readlines
        while o = stderr.gets
          if (not ignore_error) or (not ignore_error[o])
            STDOUT.write o
          end
        end
      }
      if status != 0
        puts "Exit Status: #{status}"
      else
        puts "OK"
      end
    end
  }
end