funit 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -0
- data/License.txt +263 -0
- data/Manifest.txt +25 -0
- data/README.txt +124 -0
- data/Rakefile +21 -0
- data/bin/funit +22 -0
- data/examples/CFD/FluxFunctions.f90 +34 -0
- data/examples/CFD/FluxFunctions.fun +47 -0
- data/examples/CFD/Gammas.f90 +7 -0
- data/examples/CFD/GasModel.f90 +16 -0
- data/examples/CFD/GasModel.fun +20 -0
- data/examples/ReadData/time_series_data.f90 +27 -0
- data/examples/ReadData/time_series_data.fun +28 -0
- data/examples/StopWatch/StopWatch.f90 +50 -0
- data/examples/StopWatch/StopWatch.fun +73 -0
- data/lib/funit.rb +35 -0
- data/lib/funit/assertions.rb +114 -0
- data/lib/funit/compiler.rb +33 -0
- data/lib/funit/functions.rb +100 -0
- data/lib/funit/testsuite.rb +197 -0
- data/test/test_compiler.rb +16 -0
- data/test/test_functions.rb +10 -0
- data/test/test_funit.rb +113 -0
- data/test/test_testsuite.rb +106 -0
- data/utils/funit-mode.el +111 -0
- metadata +98 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'funit/testsuite'
|
3
|
+
|
4
|
+
class TestTestSuite < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
File.rm_f(*Dir["dummyf90test*"])
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
File.rm_f(*Dir["dummyf90test*"])
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_nonexistent_funit_file_is_not_created
|
15
|
+
Funit::TestSuite.new 'dummyf90test'
|
16
|
+
assert !File.exists?("dummyf90test.fun")
|
17
|
+
assert !File.exists?("dummyf90test_fun.f90")
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_funit_file funit_contents
|
21
|
+
File.open('dummyf90test.f90','w') do |f|
|
22
|
+
f.puts "module dummyf90test\nend module dummyf90test"
|
23
|
+
end
|
24
|
+
File.open('dummyf90test.fun','w') do |f|
|
25
|
+
f.puts funit_contents
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@@compileCommand = "#{ENV['FC']} -c dummyf90test.f90 dummyf90test_fun.f90"
|
30
|
+
|
31
|
+
def test_bare_minimum_funit_file_compiles
|
32
|
+
create_funit_file ""
|
33
|
+
Funit::TestSuite.new 'dummyf90test'
|
34
|
+
assert system(@@compileCommand)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_module_variables_allowed
|
38
|
+
create_funit_file "integer :: a"
|
39
|
+
Funit::TestSuite.new 'dummyf90test'
|
40
|
+
assert system(@@compileCommand)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_blank_setup_compiles
|
44
|
+
create_funit_file "beginSetup\nendSetup"
|
45
|
+
Funit::TestSuite.new 'dummyf90test'
|
46
|
+
assert system(@@compileCommand)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_blank_test_gives_warning
|
50
|
+
create_funit_file "beginTest bob\nendTest"
|
51
|
+
Funit::TestSuite.new 'dummyf90test'
|
52
|
+
assert system(@@compileCommand)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_single_assert_test_compiles
|
56
|
+
create_funit_file "beginTest assertTrue\nIsTrue(.true.)\nendTest"
|
57
|
+
Funit::TestSuite.new 'dummyf90test'
|
58
|
+
assert system(@@compileCommand)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_matrix_assert_compiles
|
62
|
+
create_funit_file <<-MATRIX
|
63
|
+
beginTest assertTrue
|
64
|
+
integer :: a(2,2)
|
65
|
+
a = 1
|
66
|
+
IsEqual(1,a(1,1))
|
67
|
+
endTest
|
68
|
+
MATRIX
|
69
|
+
Funit::TestSuite.new 'dummyf90test'
|
70
|
+
assert system(@@compileCommand)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_simple_real_equals_assert_works
|
74
|
+
create_funit_file <<-REALEQUALS
|
75
|
+
beginTest assert_equals
|
76
|
+
real :: real_var
|
77
|
+
real_var = 1.0
|
78
|
+
IsRealEqual(1.0,real_var)
|
79
|
+
endTest
|
80
|
+
REALEQUALS
|
81
|
+
Funit::TestSuite.new 'dummyf90test'
|
82
|
+
assert system(@@compileCommand)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_real_equals_assert_works_with_function
|
86
|
+
create_funit_file <<-REQUALSFUNC
|
87
|
+
beginTest assert_equals_for_function
|
88
|
+
IsRealEqual(0.0,balance(0.0,0.0))
|
89
|
+
endTest
|
90
|
+
function balance( left, right)
|
91
|
+
real :: balance
|
92
|
+
real, intent(in) :: left, right
|
93
|
+
balance = 0.5*(left+right)
|
94
|
+
end function balance
|
95
|
+
REQUALSFUNC
|
96
|
+
Funit::TestSuite.new 'dummyf90test'
|
97
|
+
assert system(@@compileCommand)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_ignore_commented_test
|
101
|
+
create_funit_file "XbeginTest bob\nendTest"
|
102
|
+
Funit::TestSuite.new 'dummyf90test'
|
103
|
+
assert_no_match( /Testbob/i, IO.readlines('dummyf90test_fun.f90').join )
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/utils/funit-mode.el
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
;; 'funit-mode.el' - a derived major mode for editing fUnit files
|
2
|
+
;;
|
3
|
+
;; INSTALLATION:
|
4
|
+
;;
|
5
|
+
;; 1) Copy 'funit-mode.el' to the system site-lisp directory, e.g.,
|
6
|
+
;;
|
7
|
+
;; /usr/share/emacs/site-lisp
|
8
|
+
;;
|
9
|
+
;; or, if you do not have root permission, somewhere local
|
10
|
+
;; and set the load-path search variable in your ~/.emacs file
|
11
|
+
;; accordingly, e.g.,
|
12
|
+
;;
|
13
|
+
;; (setq load-path (append load-path '("~/lisp")))
|
14
|
+
;;
|
15
|
+
;; 2) To automatically activate funit-mode when visiting files,
|
16
|
+
;; add the following lines to your ~/.emacs file:
|
17
|
+
;;
|
18
|
+
;; (autoload 'funit-mode "funit-mode"
|
19
|
+
;; "Mode for editing fUnit files.")
|
20
|
+
;; (setq auto-mode-alist
|
21
|
+
;; (cons '("\\.fun$" . funit-mode) auto-mode-alist))
|
22
|
+
|
23
|
+
(define-derived-mode funit-mode
|
24
|
+
f90-mode "fUnit"
|
25
|
+
"Major mode for fUnit files (derived from F90 mode).\n\n
|
26
|
+
\\{funit-mode-map}"
|
27
|
+
(interactive)
|
28
|
+
(message "fUnit mode.")
|
29
|
+
)
|
30
|
+
|
31
|
+
;; add some new font-locks to f90's extensive list
|
32
|
+
(font-lock-add-keywords 'funit-mode
|
33
|
+
'(("\\<IsFalse\\>" . font-lock-function-name-face)
|
34
|
+
("\\<IsEqual\\>" . font-lock-function-name-face)
|
35
|
+
("\\<IsRealEqual\\>" . font-lock-function-name-face)
|
36
|
+
("\\<IsTrue\\>" . font-lock-function-name-face)
|
37
|
+
("\\<IsEqualWithin\\>" . font-lock-function-name-face)
|
38
|
+
("\\<beginTest\\>" . font-lock-builtin-face)
|
39
|
+
("\\<endTest\\>" . font-lock-builtin-face)
|
40
|
+
("\\<beginTeardown\\>" . font-lock-builtin-face)
|
41
|
+
("\\<endTeardown\\>" . font-lock-builtin-face)
|
42
|
+
("\\<beginSetup\\>" . font-lock-builtin-face)
|
43
|
+
("\\<endSetup\\>" . font-lock-builtin-face))
|
44
|
+
)
|
45
|
+
|
46
|
+
(defvar funit-buffer-command "funit"
|
47
|
+
"Shell command used by the \\[funit-test-buffer] function.")
|
48
|
+
|
49
|
+
;;(defvar compilation-buffer-name-function "* fUnit output *")
|
50
|
+
|
51
|
+
;; run fUnit on the current buffer:
|
52
|
+
(defun funit-test-buffer ()
|
53
|
+
"Excute \\[funit-buffer-command] on the file associated
|
54
|
+
with the current buffer."
|
55
|
+
(interactive)
|
56
|
+
; (compile funit-buffer-command);; (file-name-nondirectory buffer-file-name)))
|
57
|
+
(save-buffer)
|
58
|
+
(shell-command-on-region (point-min) (point-max) funit-buffer-command funit-error-buffer)
|
59
|
+
)
|
60
|
+
|
61
|
+
;; key-binding for running fUnit on the current buffer
|
62
|
+
(define-key funit-mode-map "\C-c\C-c" 'funit-test-buffer)
|
63
|
+
|
64
|
+
;; add fUnit error regex to compilation mode:
|
65
|
+
;; blah, blah, blak [FluxFunctions.fun:34]
|
66
|
+
;(require 'compile)
|
67
|
+
;(setq compilation-error-regexp-alist
|
68
|
+
; (cons '("\\[\\(.+\\):\\([0-9]+\\)\\]" 1 2) compilation-error-regexp-alist)
|
69
|
+
;)
|
70
|
+
|
71
|
+
(defvar funit-error-buffer
|
72
|
+
"*fUnit output-buffer*"
|
73
|
+
"Buffer name for error messages used by `funit-next-error'")
|
74
|
+
|
75
|
+
(defvar funit-error-message-regexp
|
76
|
+
"\\[.+:\\([0-9]+\\)\\]"
|
77
|
+
"Regular expression used by `funit-next-error' to find error messages.
|
78
|
+
The sub-expression between the first capturing parens must be the line
|
79
|
+
number where the error occured")
|
80
|
+
|
81
|
+
(defun funit-next-error ()
|
82
|
+
"Goto line in current buffer indicated by next error message in `funit-error-buffer'
|
83
|
+
|
84
|
+
Assumes that the point is positioned before the first occurance of
|
85
|
+
`funit-error-message-regexp' in the `funit-error-buffer' before the first
|
86
|
+
call to this function.
|
87
|
+
|
88
|
+
See also `funit-error-message-regexp' `funit-error-buffer'"
|
89
|
+
|
90
|
+
(interactive)
|
91
|
+
(let ((error-line-number))
|
92
|
+
(save-current-buffer
|
93
|
+
(set-buffer (or (get-buffer funit-error-buffer)
|
94
|
+
(error
|
95
|
+
(concat
|
96
|
+
"Can't find the error buffer: "
|
97
|
+
funit-error-buffer))))
|
98
|
+
(if (re-search-forward funit-error-message-regexp nil t)
|
99
|
+
(progn
|
100
|
+
(setq error-line-number
|
101
|
+
(string-to-number
|
102
|
+
(buffer-substring (match-beginning 1)
|
103
|
+
(match-end 1))))
|
104
|
+
(goto-char (1+ (match-end 1))))))
|
105
|
+
(if error-line-number
|
106
|
+
(goto-line error-line-number)
|
107
|
+
(message "No more errors"))))
|
108
|
+
|
109
|
+
(provide 'funit-mode)
|
110
|
+
|
111
|
+
;; end of 'funit-mode.el'
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: funit
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.9.0
|
7
|
+
date: 2007-08-02 00:00:00 -04:00
|
8
|
+
summary: A Fortran unit testing framework.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: funit-support@rubyforge.org
|
12
|
+
homepage: http://rubyforge.org/projects/funit
|
13
|
+
rubyforge_project: nasarb
|
14
|
+
description: "== DESCRIPTION: FUnit is a unit testing framework for Fortran modules. Unit tests are written as Fortran fragments that use a small set of testing-specific keywords and functions. FUnit transforms these fragments into valid Fortran code, compiles, links, and runs them against the module under test."
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Karen Bibb
|
31
|
+
- Bil Kleb
|
32
|
+
- Beth Lee-Rausch
|
33
|
+
- Mike Park
|
34
|
+
- Bill Wood
|
35
|
+
files:
|
36
|
+
- History.txt
|
37
|
+
- License.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- bin/funit
|
42
|
+
- examples/CFD/FluxFunctions.f90
|
43
|
+
- examples/CFD/FluxFunctions.fun
|
44
|
+
- examples/CFD/Gammas.f90
|
45
|
+
- examples/CFD/GasModel.f90
|
46
|
+
- examples/CFD/GasModel.fun
|
47
|
+
- examples/ReadData/time_series_data.f90
|
48
|
+
- examples/ReadData/time_series_data.fun
|
49
|
+
- examples/StopWatch/StopWatch.f90
|
50
|
+
- examples/StopWatch/StopWatch.fun
|
51
|
+
- lib/funit.rb
|
52
|
+
- lib/funit/assertions.rb
|
53
|
+
- lib/funit/compiler.rb
|
54
|
+
- lib/funit/functions.rb
|
55
|
+
- lib/funit/testsuite.rb
|
56
|
+
- test/test_compiler.rb
|
57
|
+
- test/test_functions.rb
|
58
|
+
- test/test_funit.rb
|
59
|
+
- test/test_testsuite.rb
|
60
|
+
- utils/funit-mode.el
|
61
|
+
test_files:
|
62
|
+
- test/test_compiler.rb
|
63
|
+
- test/test_testsuite.rb
|
64
|
+
- test/test_funit.rb
|
65
|
+
- test/test_functions.rb
|
66
|
+
rdoc_options:
|
67
|
+
- --main
|
68
|
+
- README.txt
|
69
|
+
extra_rdoc_files:
|
70
|
+
- History.txt
|
71
|
+
- License.txt
|
72
|
+
- Manifest.txt
|
73
|
+
- README.txt
|
74
|
+
executables:
|
75
|
+
- funit
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
dependencies:
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: fortran
|
83
|
+
version_requirement:
|
84
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.0.0
|
89
|
+
version:
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: hoe
|
92
|
+
version_requirement:
|
93
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.2.2
|
98
|
+
version:
|