fUnit 0.0.2 → 0.0.3

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.
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Apr 09 00:44:26 EDT 2006</td>
59
+ <td>Sat Apr 15 10:41:30 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -71,21 +71,40 @@
71
71
  <div id="description">
72
72
  <h1>FUnit: a Fortran Unit Testing Framework</h1>
73
73
  <p>
74
- FUnit is a unit testing framework for Fortran modules. Unit tests are
75
- written in Fortran fragments that use a small set of testing-specific
76
- extensions. FUnit transforms these fragments into valid Fortran code and
77
- compiles, links, and runs them against the module under test.
74
+ FUnit is a <a href="http://en.wikipedia.org/wiki/Unit_testing">unit
75
+ testing</a> framework for Fortran modules.
78
76
  </p>
79
- <h2>Prerequisites</h2>
80
- <ol>
81
- <li>A Fortran 90/95/2003 compiler (set via F9X environment variable)
77
+ <p>
78
+ Unit tests are written in Fortran fragments that use a small set of
79
+ testing-specific keywords and functions. FUnit transforms these fragments
80
+ into valid Fortran code and compiles, links, and runs them against the
81
+ module under test.
82
+ </p>
83
+ <p>
84
+ FUnit is <a
85
+ href="http://www.oreillynet.com/pub/a/network/2005/08/30/ruby-rails-david-heinemeier-hansson.html">opinionated
86
+ software</a> which values convention over configuration. Specifically,
87
+ fUnit requires a Fortran 95 compiler, it only supports testing routines
88
+ contained in modules, it requires tests to be stored along side the code
89
+ under test, and it requires that you follow a specific naming rule for test
90
+ files.
91
+ </p>
92
+ <ul>
93
+ <li>Documentation: <a href="http://funit.rubyforge.org">funit.rubyforge.org</a>
82
94
 
83
95
  </li>
84
- <li><a href="http://www.ruby-lang.org/">The Ruby language</a>
96
+ <li>Project Page: <a
97
+ href="http://rubyforge.org/projects/funit">rubyforge.org/projects/funit</a>
85
98
 
86
99
  </li>
87
- <li><a href="http://rubyforge.org/projects/rubygems/">RubyGems package
88
- manager</a>
100
+ </ul>
101
+ <h2>Requirements</h2>
102
+ <ol>
103
+ <li>A Fortran 90/95/2003 compiler (set via F9X environment variable)
104
+
105
+ </li>
106
+ <li><a href="http://www.ruby-lang.org/">The Ruby language</a> with the <a
107
+ href="http://rubyforge.org/projects/rubygems/">RubyGems package manager</a>
89
108
 
90
109
  </li>
91
110
  </ol>
@@ -93,18 +112,117 @@ manager</a>
93
112
  <pre>
94
113
  gem install funit
95
114
  </pre>
115
+ <h2>Example</h2>
116
+ <p>
117
+ Suppose you have a module in <tt>gas_physics.f90</tt> that contains a
118
+ routine that returns viscosity as a function of temperature,
119
+ </p>
120
+ <pre>
121
+ module gas_physics
122
+ ..
123
+ contains
124
+ ..
125
+ function viscosity(temperature)
126
+ real :: viscosity, temperature
127
+ viscosity = 2.0e-3 * temperature**1.5
128
+ end function
129
+ ..
130
+ end module
131
+ </pre>
132
+ <p>
133
+ The tests of this module would be contained in <tt>gas_physicsMT.ftk</tt>,
134
+ and might contain a test like,
135
+ </p>
136
+ <pre>
137
+ ..
138
+ beginTest viscosity_varies_as_temperature
139
+ IsRealEqual( 0.0, viscosity(0.0) )
140
+ IsEqualWithin( 0.7071, viscosity(50.0), 1e-3 )
141
+ endTest
142
+ ..
143
+ </pre>
144
+ <p>
145
+ This brief fragment is all you need, the framework provides the rest of the
146
+ trappings to turn this into valid Fortran code.
147
+ </p>
148
+ <p>
149
+ You would run the tests for the <tt>gas_physics</tt> module with the
150
+ command,
151
+ </p>
152
+ <pre>
153
+ funit gas_physics
154
+ </pre>
155
+ <p>
156
+ which would transform your fragments contained in
157
+ <tt>gas_physicsMT.ftk</tt> into valid Fortran code, create a test runner
158
+ program, compile everything, and run the tests. A sample output would look
159
+ like,
160
+ </p>
161
+ <pre>
162
+ parsing gas_physicsMT.ftk
163
+ computing dependencies
164
+ locating associated source files and sorting for compilation
165
+ g95 -o TestRunner
166
+ gas_physics.f90 \
167
+ gas_physicsMT.f90 \
168
+ TestRunner.f90
169
+
170
+ gas_physics test suite:
171
+ Passed 2 of 2 possible asserts comprising 1 of 1 tests.
172
+ </pre>
173
+ <h2>Support</h2>
174
+ <p>
175
+ Send email to funit-support@rubyforge.org or submit a request through <a
176
+ href="http://rubyforge.org/tracker/?group_id=1416">rubyforge.org/tracker/?group_id=1416</a>.
177
+ </p>
178
+ <h2>License</h2>
179
+ <p>
180
+ FUnit is released under the NASA Open Source Agreement, which requests
181
+ registration. If you would like to register, send an email to
182
+ funit-support@rubyforge.org with your name, institution (if applicable),
183
+ city, postal code, and country. See <a
184
+ href="http://funit.rubyforge.org/files/COPYING.html">COPYING</a> for
185
+ details.
186
+ </p>
187
+ <h2>A Brief History</h2>
188
+ <p>
189
+ On October 4, 2001, Mike Hill (then of <a
190
+ href="http://www.objectmentor.com/">Object Mentor</a>, now of <a
191
+ href="http://www.industriallogic.com">Industrial Logic</a>) visited NASA
192
+ Langley Research Center in Hampton, Virginia and gave a test-first design
193
+ talk at Institute for Computer and Applied Sciences and Engineering
194
+ (ICASE). Copies of his slides are available at <a
195
+ href="http://www.icase.edu/series/MPP/">icase.edu/series/MPP</a>.
196
+ </p>
197
+ <p>
198
+ Mike spent the afternoon with Bil Kleb, Bill Wood, Karen Bibb, and Mike
199
+ Park reasoning out how we might create a testing framework for Fortran 90
200
+ to use during <a href="http://fun3d.larc.nasa.gov">FUN3D</a> code
201
+ development. By the end of the afternoon we had a working protoype based on
202
+ the macro expansion techniques employed in Mike Hill&#8217;s <a
203
+ href="http://sourceforge.net/projects/cpptestkit">cpptestkit</a>. We
204
+ quickly found C-preprocessor macros to be to restrictive and rewrote the
205
+ framework in <a href="http:www.ruby-lang.org">Ruby</a>.
206
+ </p>
96
207
  <h2>To Do</h2>
97
208
  <ul>
98
- <li>Make tests so that they fail gracefully if Fortran compiler not found.
209
+ <li>Make tests fail gracefully if Fortran compiler is not found.
210
+
211
+ </li>
212
+ <li>Complete migration rom CamelCase to snake_case for methods and variables.
99
213
 
100
214
  </li>
101
- <li>Work out RubyGEM packaging kinks.
215
+ <li>Use &#8216;test&#8217; keyword instead of &#8216;beginTest&#8217; business.
102
216
 
103
217
  </li>
104
- <li>Change from CamelCase to snake_case.
218
+ <li>Don&#8216;t add to test name during translation to avoid 32 character limit
219
+ trouble.
105
220
 
106
221
  </li>
107
- <li>Use &#8216;test&#8217; keyword instead of &#8216;beginTest&#8217; business.
222
+ <li>Rename assertions to more consistent with other xUnits.
223
+
224
+ </li>
225
+ <li>Add assertions to capture stops and warning messages.
108
226
 
109
227
  </li>
110
228
  <li>Clean up documentation.
@@ -114,6 +232,20 @@ manager</a>
114
232
  Veenstra&#8217;s <a
115
233
  href="http://www.erikveen.dds.nl/rubyscript2exe/">RubyScript2Exe</a>.
116
234
 
235
+ </li>
236
+ <li>Use a makefile instead of a single, ordered command line for compilation.
237
+
238
+ </li>
239
+ <li>Add a clean option to remove all generated artifacts.
240
+
241
+ </li>
242
+ <li>Migrate to a new naming convention? E.g., gas_physics.fun -&gt;
243
+ gas_physics_fun.f90
244
+
245
+ </li>
246
+ <li>Change Fortran envinoment variable from <tt>F9X</tt> to GNU-standard
247
+ <tt>FC</tt>.
248
+
117
249
  </li>
118
250
  </ul>
119
251
 
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 05 22:06:56 EDT 2006</td>
59
+ <td>Thu Apr 13 15:31:36 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,12 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Define Fortran assertion macros
74
+ </p>
75
+
76
+ </div>
71
77
 
72
78
 
73
79
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Apr 09 00:52:33 EDT 2006</td>
59
+ <td>Thu Apr 13 15:32:36 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -70,7 +70,7 @@
70
70
 
71
71
  <div id="description">
72
72
  <p>
73
- This scripts finds dependencies for f90 code
73
+ Find Fortran dependencies
74
74
  </p>
75
75
 
76
76
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Apr 09 00:59:16 EDT 2006</td>
59
+ <td>Thu Apr 13 15:33:45 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,12 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Compile and run the requested tests
74
+ </p>
75
+
76
+ </div>
71
77
 
72
78
 
73
79
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 05 21:59:01 EDT 2006</td>
59
+ <td>Thu Apr 13 15:34:19 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,12 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Create test suite wrapper code
74
+ </p>
75
+
76
+ </div>
71
77
 
72
78
 
73
79
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Apr 09 01:00:46 EDT 2006</td>
59
+ <td>Thu Apr 13 15:30:12 EDT 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,12 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Define a method to find and run all tests
74
+ </p>
75
+
76
+ </div>
71
77
 
72
78
  <div id="requires-list">
73
79
  <h3 class="section-bar">Required files</h3>
@@ -1,7 +1,7 @@
1
1
  ! FluxFunctionsMT.f90 - a Fortran mobility test suite for FluxFunctions.f90
2
2
  !
3
3
  ! [dynamically generated from FluxFunctionsMT.ftk
4
- ! by funit Ruby script Sun Apr 09 01:08:26 EDT 2006]
4
+ ! by funit Ruby script Sun Apr 09 01:22:59 EDT 2006]
5
5
 
6
6
  module FluxFunctionsMT
7
7
 
@@ -20,7 +20,7 @@ module FluxFunctionsMT
20
20
  integer :: numAssertsTested = 0
21
21
  integer :: numFailures = 0
22
22
 
23
- ! $Id: FluxFunctionsTS.ftk 91 2001-11-13 20:46:28Z cvs4bk $
23
+ ! $Id: FluxFunctionsMT.ftk 139 2006-04-09 05:17:47Z kleb $
24
24
 
25
25
  real :: leftState, rightState, interfaceFlux
26
26
 
@@ -1,4 +1,4 @@
1
- ! $Id: FluxFunctionsTS.ftk 91 2001-11-13 20:46:28Z cvs4bk $
1
+ ! $Id: FluxFunctionsMT.ftk 139 2006-04-09 05:17:47Z kleb $
2
2
 
3
3
  real :: leftState, rightState, interfaceFlux
4
4
 
@@ -1,7 +1,7 @@
1
1
  ! GasModelMT.f90 - a Fortran mobility test suite for GasModel.f90
2
2
  !
3
3
  ! [dynamically generated from GasModelMT.ftk
4
- ! by funit Ruby script Sun Apr 09 01:08:39 EDT 2006]
4
+ ! by funit Ruby script Sun Apr 09 01:10:35 EDT 2006]
5
5
 
6
6
  module GasModelMT
7
7
 
@@ -1,4 +1,4 @@
1
- ! $Id: GasModelTS.ftk 91 2001-11-13 20:46:28Z cvs4bk $
1
+ ! $Id: GasModelMT.ftk 139 2006-04-09 05:17:47Z kleb $
2
2
 
3
3
  real :: Pressure, Density, Energy
4
4
 
@@ -1,18 +1,18 @@
1
1
  ! TestRunner.f90 - runs Fortran mobility test suites
2
2
  !
3
- ! [Dynamically generated by funit Ruby script Sun Apr 09 01:08:39 EDT 2006.]
3
+ ! [Dynamically generated by funit Ruby script Sun Apr 09 01:22:59 EDT 2006.]
4
4
 
5
5
  program TestRunner
6
6
 
7
- use GasModelMT
7
+ use FluxFunctionsMT
8
8
 
9
9
  implicit none
10
10
 
11
11
  integer :: numTests, numAsserts, numAssertsTested, numFailures
12
12
 
13
13
  print *, ""
14
- print *, "GasModel test suite:"
15
- call MTGasModel( numTests, &
14
+ print *, "FluxFunctions test suite:"
15
+ call MTFluxFunctions( numTests, &
16
16
  numAsserts, numAssertsTested, numFailures )
17
17
  print *, "Passed", numAssertsTested, "of", numAsserts, &
18
18
  "possible asserts comprising", &
@@ -1,7 +1,7 @@
1
1
  ! StopWatchMT.f90 - a Fortran mobility test suite for StopWatch.f90
2
2
  !
3
3
  ! [dynamically generated from StopWatchMT.ftk
4
- ! by funit Ruby script Sun Apr 09 01:07:09 EDT 2006]
4
+ ! by funit Ruby script Thu Apr 13 17:37:19 EDT 2006]
5
5
 
6
6
  module StopWatchMT
7
7
 
@@ -1,6 +1,6 @@
1
1
  ! TestRunner.f90 - runs Fortran mobility test suites
2
2
  !
3
- ! [Dynamically generated by funit Ruby script Sun Apr 09 01:07:09 EDT 2006.]
3
+ ! [Dynamically generated by funit Ruby script Thu Apr 13 17:37:19 EDT 2006.]
4
4
 
5
5
  program TestRunner
6
6
 
@@ -1,3 +1,13 @@
1
+ # Define Fortran assertion macros
2
+ #--
3
+ # Copyright 2006 United States Government as represented by
4
+ # NASA Langley Research Center. No copyright is claimed in
5
+ # the United States under Title 17, U.S. Code. All Other Rights
6
+ # Reserved.
7
+ #
8
+ # This file is governed by the NASA Open Source Agreement.
9
+ # See COPYING for details.
10
+ #++
1
11
  module Funit
2
12
  module Assertions
3
13
 
@@ -1,4 +1,14 @@
1
+ # Find Fortran dependencies
2
+ #--
1
3
  # This scripts finds dependencies for f90 code
4
+ # Copyright 2006 United States Government as represented by
5
+ # NASA Langley Research Center. No copyright is claimed in
6
+ # the United States under Title 17, U.S. Code. All Other Rights
7
+ # Reserved.
8
+ #
9
+ # This file is governed by the NASA Open Source Agreement.
10
+ # See COPYING for details.
11
+ #++
2
12
 
3
13
  raise "Need Ruby version >= 1.8, current using #{VERSION}" unless String.instance_methods.include? "match"
4
14
 
@@ -97,7 +107,7 @@ module Funit
97
107
  @parsed.clear
98
108
  source_file_dependencies( head_f90 )
99
109
  sources = Array.new
100
- while !@file_dependencies.empty? do
110
+ while ! @file_dependencies.empty? do
101
111
  no_dependents_pair = @file_dependencies.detect{ |h,d| d == [] }
102
112
  no_dependents = no_dependents_pair.first
103
113
  sources.push no_dependents
@@ -1,3 +1,13 @@
1
+ # Compile and run the requested tests
2
+ #--
3
+ # Copyright 2006 United States Government as represented by
4
+ # NASA Langley Research Center. No copyright is claimed in
5
+ # the United States under Title 17, U.S. Code. All Other Rights
6
+ # Reserved.
7
+ #
8
+ # This file is governed by the NASA Open Source Agreement.
9
+ # See COPYING for details.
10
+ #++
1
11
  module Funit
2
12
 
3
13
  class Compiler
@@ -1,3 +1,13 @@
1
+ # Create test suite wrapper code
2
+ #--
3
+ # Copyright 2006 United States Government as represented by
4
+ # NASA Langley Research Center. No copyright is claimed in
5
+ # the United States under Title 17, U.S. Code. All Other Rights
6
+ # Reserved.
7
+ #
8
+ # This file is governed by the NASA Open Source Agreement.
9
+ # See COPYING for details.
10
+ #++
1
11
  module Funit
2
12
 
3
13
  include Funit::Assertions
data/lib/funit.rb CHANGED
@@ -1,3 +1,14 @@
1
+ # Define a method to find and run all tests
2
+ #--
3
+ # Copyright 2006 United States Government as represented by
4
+ # NASA Langley Research Center. No copyright is claimed in
5
+ # the United States under Title 17, U.S. Code. All Other Rights
6
+ # Reserved.
7
+ #
8
+ # This file is governed by the NASA Open Source Agreement.
9
+ # See COPYING for details.
10
+ #++
11
+
1
12
  require 'funit/functions'
2
13
  require 'funit/fortran_deps'
3
14
  require 'funit/assertions'
@@ -69,6 +69,37 @@ class TestTestSuite < Test::Unit::TestCase
69
69
  assert system(@@compileCommand)
70
70
  end
71
71
 
72
+ def test_simple_real_equals_assert_works
73
+ create_FTK_file <<-REQFTK
74
+ beginTest assert_equals
75
+ real :: real_var
76
+ real_var = 1.0
77
+ IsRealEqual(real_var,1.0)
78
+ endTest
79
+ REQFTK
80
+ Funit::TestSuite.new 'dummyf90test'
81
+ puts `cat dummyf90testMT.ftk`
82
+ puts `cat dummyf90testMT.f90`
83
+ assert system(@@compileCommand)
84
+ end
85
+
86
+ def test_real_equals_assert_works_with_function
87
+ create_FTK_file <<-REQFTK
88
+ function balance( left, right)
89
+ real :: balance
90
+ real, intent(in) :: left, right
91
+ balance = 0.5*(left+right)
92
+ end function balance
93
+ beginTest assert_equals_for_function
94
+ IsRealEqual(balance(0.0,0.0),0.0)
95
+ endTest
96
+ REQFTK
97
+ Funit::TestSuite.new 'dummyf90test'
98
+ puts `cat dummyf90testMT.ftk`
99
+ puts `cat dummyf90testMT.f90`
100
+ assert system(@@compileCommand)
101
+ end
102
+
72
103
  def test_ignore_commented_test
73
104
  create_FTK_file "XbeginTest bob\nendTest"
74
105
  Funit::TestSuite.new 'dummyf90test'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: fUnit
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2006-04-09 00:00:00 -04:00
6
+ version: 0.0.3
7
+ date: 2006-04-15 00:00:00 -04:00
8
8
  summary: A Fortran Unit Testing Framework
9
9
  require_paths:
10
10
  - lib
@@ -22,9 +22,9 @@ has_rdoc: true
22
22
  required_ruby_version: !ruby/object:Gem::Version::Requirement
23
23
  requirements:
24
24
  -
25
- - ">"
25
+ - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.0.0
27
+ version: 1.8.1
28
28
  version:
29
29
  platform: ruby
30
30
  signing_key:
@@ -36,7 +36,6 @@ files:
36
36
  - Rakefile
37
37
  - README
38
38
  - bin/funit
39
- - docs/HISTORY
40
39
  - docs/html
41
40
  - docs/spiel
42
41
  - docs/why
@@ -107,10 +106,8 @@ files:
107
106
  - examples/StopWatch/stopwatchmt.mod
108
107
  - examples/StopWatch/TestRunner
109
108
  - examples/StopWatch/TestRunner.f90
110
- - lib/clean
111
109
  - lib/funit
112
110
  - lib/funit.rb
113
- - lib/mklinks
114
111
  - lib/funit/assertions.rb
115
112
  - lib/funit/fortran_deps.rb
116
113
  - lib/funit/functions.rb
@@ -132,5 +129,6 @@ extra_rdoc_files:
132
129
  executables:
133
130
  - funit
134
131
  extensions: []
135
- requirements: []
132
+ requirements:
133
+ - "Registration appreciated -- see fun3d.larc.nasa.gov"
136
134
  dependencies: []
data/docs/HISTORY DELETED
@@ -1,20 +0,0 @@
1
- $Id: HISTORY 112 2006-04-05 11:23:45Z kleb $
2
-
3
- A BRIEF HISTORY
4
-
5
- On October 4, 2001, Mike Hill of Object Mentor, Inc. visited NASA
6
- Langley Research Center in Hampton, Virginia and gave a test-first
7
- design talk at Institute for Computer and Applied Sciences and
8
- Engineering (ICASE).
9
-
10
- Mike spent the afternoon with Bil Kleb, Bill Wood, Karen Bibb,
11
- and Mike Park reasoning out how we might create a testing framework
12
- for Fortran 90. By the end of the afternoon we had a working
13
- protoype based on the macro expansion techniques employeed in
14
- Mike's own cpptestkit.
15
-
16
- The basic idea is that test routines should easily be written in
17
- a psuedo-Fortran style (i.e., very lightweight), processed (via
18
- the c preproccesor or a script) into valid Fortran90, collected, and
19
- invoked by a dynamically-created/compiled/ linked/run Fortran90 code
20
- named testrunner.
data/lib/clean DELETED
@@ -1 +0,0 @@
1
- rm -rf *TS.f90 *.o *.mod TestRunner*
data/lib/mklinks DELETED
@@ -1,5 +0,0 @@
1
- ln -s ../examples/CFD/GasModel.f90 .
2
- ln -s ../examples/CFD/GasModelTS.ftk .
3
- ln -s ../examples/CFD/Gammas.f90 .
4
- ln -s ../examples/CFD/FluxFunctions.f90 .
5
- ln -s ../examples/CFD/FluxFunctionsTS.ftk .