fUnit 0.0.1 → 0.0.2

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.
Files changed (48) hide show
  1. data/{LICENSE → COPYING} +21 -21
  2. data/README +26 -2
  3. data/Rakefile +97 -0
  4. data/docs/html/classes/Funit.html +390 -0
  5. data/docs/html/classes/Funit/Assertions.html +285 -0
  6. data/docs/html/classes/Funit/Compiler.html +160 -0
  7. data/docs/html/classes/Funit/Depend.html +441 -0
  8. data/docs/html/classes/Funit/TestSuite.html +417 -0
  9. data/docs/html/created.rid +1 -0
  10. data/docs/html/files/COPYING.html +563 -0
  11. data/docs/html/files/README.html +151 -0
  12. data/docs/html/files/lib/funit/assertions_rb.html +101 -0
  13. data/docs/html/files/lib/funit/fortran_deps_rb.html +107 -0
  14. data/docs/html/files/lib/funit/functions_rb.html +101 -0
  15. data/docs/html/files/lib/funit/test_suite_rb.html +101 -0
  16. data/docs/html/files/lib/funit_rb.html +111 -0
  17. data/docs/html/fr_class_index.html +31 -0
  18. data/docs/html/fr_file_index.html +33 -0
  19. data/docs/html/fr_method_index.html +59 -0
  20. data/docs/html/index.html +24 -0
  21. data/docs/html/rdoc-style.css +208 -0
  22. data/examples/CFD/FluxFunctions.f90 +35 -0
  23. data/examples/CFD/FluxFunctionsMT.f90 +336 -0
  24. data/examples/CFD/FluxFunctionsMT.ftk +49 -0
  25. data/examples/CFD/Gammas.f90 +8 -0
  26. data/examples/CFD/GasModel.f90 +17 -0
  27. data/examples/CFD/GasModelMT.f90 +173 -0
  28. data/examples/CFD/GasModelMT.ftk +22 -0
  29. data/examples/CFD/TestRunner +0 -0
  30. data/examples/CFD/TestRunner.f90 +23 -0
  31. data/examples/CFD/fluxfunctions.mod +45 -0
  32. data/examples/CFD/gammas.mod +20 -0
  33. data/examples/CFD/gasmodel.mod +30 -0
  34. data/examples/CFD/gasmodelmt.mod +27 -0
  35. data/examples/StopWatch/StopWatch.f90 +50 -0
  36. data/examples/StopWatch/StopWatchMT.f90 +343 -0
  37. data/examples/StopWatch/StopWatchMT.ftk +73 -0
  38. data/examples/StopWatch/TestRunner +0 -0
  39. data/examples/StopWatch/TestRunner.f90 +23 -0
  40. data/examples/StopWatch/stopwatch.mod +34 -0
  41. data/examples/StopWatch/stopwatchmt.mod +27 -0
  42. data/lib/funit.rb +1 -6
  43. data/lib/funit/fortran_deps.rb +112 -0
  44. data/lib/funit/functions.rb +2 -5
  45. data/tests/tc_fortran_deps.rb +2 -2
  46. metadata +73 -22
  47. data/INSTALL +0 -19
  48. data/lib/fortran_deps.rb +0 -109
@@ -0,0 +1,73 @@
1
+ integer, dimension(8) :: dateAndTime1, dateAndTime2
2
+ real :: seconds
3
+
4
+ beginSetup
5
+ NotInitialized = .TRUE.
6
+ last = 0
7
+ seconds = HUGE(0.0)
8
+ endSetup
9
+
10
+ beginTest SystemDateAndTimeWorks
11
+ call date_and_time(values=dateAndTime1)
12
+ IsTrue( dateAndTime1(1) /= -huge(0) )
13
+ IsTrue( size(dateAndTime1,1) == 8 )
14
+ endTest
15
+
16
+ ! test secBetween
17
+ beginTest OneMSecDifference
18
+ dateAndTime1 = (/ 2000, 1, 1, 0, 0, 0, 0, 0 /)
19
+ dateAndTime2 = (/ 2000, 1, 1, 0, 0, 0, 0, 1 /)
20
+ seconds = SecBetween(dateAndTime1, dateAndTime2)
21
+ IsRealEqual(seconds, 0.001)
22
+ endTest
23
+
24
+ beginTest MinuteRollover
25
+ dateAndTime1 = (/ 2000, 1, 1, 0, 0, 0,59, 0 /)
26
+ dateAndTime2 = (/ 2000, 1, 1, 0, 0, 1, 0, 0 /)
27
+ seconds = SecBetween(dateAndTime1, dateAndTime2)
28
+ IsRealEqual(seconds, 1.0)
29
+ endTest
30
+
31
+ ! test secSinceLast
32
+ beginTest InitializationState
33
+ IsTrue(notInitialized)
34
+ seconds = secSinceLast()
35
+ IsFalse(notInitialized)
36
+ seconds = secSinceLast()
37
+ IsFalse(notInitialized)
38
+ endTest
39
+
40
+ beginTest InitiallyReturnsZero
41
+ seconds = secSinceLast()
42
+ IsRealEqual(seconds, 0.0)
43
+ call timeDelay(seconds)
44
+ seconds = secSinceLast()
45
+ IsTrue( seconds /= 0.0 )
46
+ endTest
47
+
48
+ subroutine timeDelay (sum)
49
+ integer :: i
50
+ real :: sum
51
+ do i = 1, 1000000
52
+ sum = sum + i
53
+ enddo
54
+ end subroutine timeDelay
55
+
56
+ beginTest ComputesSeconds
57
+ seconds = secSinceLast()
58
+ call timeDelay (seconds)
59
+ seconds = secSinceLast()
60
+ IsTrue( seconds > 0.0 )
61
+ endTest
62
+
63
+ beginTest ComputesSecondsSpecial
64
+ real :: expectedSeconds
65
+
66
+ seconds = secSinceLast()
67
+ dateAndTime1 = last
68
+ call timeDelay (seconds)
69
+ seconds = secSinceLast()
70
+ dateAndTime2 = last
71
+ expectedSeconds = secBetween(dateAndTime1,dateAndTime2)
72
+ IsRealEqual(seconds, expectedSeconds)
73
+ endTest
Binary file
@@ -0,0 +1,23 @@
1
+ ! TestRunner.f90 - runs Fortran mobility test suites
2
+ !
3
+ ! [Dynamically generated by funit Ruby script Sun Apr 09 01:07:09 EDT 2006.]
4
+
5
+ program TestRunner
6
+
7
+ use StopWatchMT
8
+
9
+ implicit none
10
+
11
+ integer :: numTests, numAsserts, numAssertsTested, numFailures
12
+
13
+ print *, ""
14
+ print *, "StopWatch test suite:"
15
+ call MTStopWatch( numTests, &
16
+ numAsserts, numAssertsTested, numFailures )
17
+ print *, "Passed", numAssertsTested, "of", numAsserts, &
18
+ "possible asserts comprising", &
19
+ numTests-numFailures, "of", numTests, "tests."
20
+
21
+ print *, ""
22
+
23
+ end program TestRunner
@@ -0,0 +1,34 @@
1
+ G95 module created on Sun Apr 9 01:07:09 2006 from ./StopWatch.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'secbetween' 'stopwatch' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
15
+ FUNCTION) (REAL 4 ()) 0 0 (3 NONE 4 NONE) () '' () ())
16
+ 5 'secsincelast' 'stopwatch' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
17
+ FUNCTION) (REAL 4 ()) 0 0 () () '' () ())
18
+ 6 'stopwatch' 'stopwatch' 1 ((MODULE UNKNOWN UNKNOWN UNKNOWN) (UNKNOWN 0
19
+ ()) 0 0 () () '' () ())
20
+ 7 'notinitialized' 'stopwatch' 1 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN) (
21
+ LOGICAL 4 ()) 0 0 () () '' () ())
22
+ 8 'last' 'stopwatch' 1 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DIMENSION) (
23
+ INTEGER 4 ()) 0 0 () (1 EXPLICIT (CONSTANT (INTEGER 4 ()) 0 '1') (
24
+ CONSTANT (INTEGER 4 ()) 0 '8')) '' () ())
25
+ 3 'begindnt' '' 9 ((VARIABLE IN UNKNOWN UNKNOWN DIMENSION DUMMY) (
26
+ INTEGER 4 ()) 0 0 () (1 EXPLICIT (CONSTANT (INTEGER 4 ()) 0 '1') (
27
+ CONSTANT (INTEGER 4 ()) 0 '8')) '' () ())
28
+ 4 'enddnt' '' 9 ((VARIABLE IN UNKNOWN UNKNOWN DIMENSION DUMMY) (INTEGER
29
+ 4 ()) 0 0 () (1 EXPLICIT (CONSTANT (INTEGER 4 ()) 0 '1') (CONSTANT (
30
+ INTEGER 4 ()) 0 '8')) '' () ())
31
+ )
32
+
33
+ ('last' 0 8 'notinitialized' 0 7 'stopwatch' 0 6 'secsincelast' 0 5
34
+ 'secbetween' 0 2)
@@ -0,0 +1,27 @@
1
+ G95 module created on Sun Apr 9 01:07:09 2006 from ./StopWatchMT.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'mtstopwatch' 'stopwatchmt' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
15
+ SUBROUTINE) (PROCEDURE 0 ()) 0 0 (3 NONE 4 NONE 5 NONE 6 NONE) () '' ()
16
+ ())
17
+ 3 'ntests' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4 ())
18
+ 0 0 () () '' () ())
19
+ 4 'nasserts' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4 ())
20
+ 0 0 () () '' () ())
21
+ 6 'nfailures' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4
22
+ ()) 0 0 () () '' () ())
23
+ 5 'nassertstested' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (
24
+ INTEGER 4 ()) 0 0 () () '' () ())
25
+ )
26
+
27
+ ('mtstopwatch' 0 2)
data/lib/funit.rb CHANGED
@@ -1,17 +1,14 @@
1
1
  require 'funit/functions'
2
+ require 'funit/fortran_deps'
2
3
  require 'funit/assertions'
3
4
  require 'funit/test_suite'
4
5
 
5
6
  module Funit
6
-
7
7
  def runAllFtks
8
-
9
8
  Compiler.new # a test for compiler env set (remove this later)
10
-
11
9
  writeTestRunner(testSuites = parseCommandLine)
12
10
 
13
11
  # convert each *MT.ftk file into a pure Fortran9x file:
14
-
15
12
  testSuites.each do |testSuite|
16
13
  testSuiteF90 = TestSuite.new(testSuite)
17
14
  end
@@ -19,7 +16,5 @@ module Funit
19
16
  compileTests testSuites
20
17
 
21
18
  raise "Failed to execute TestRunner" unless system("./TestRunner")
22
-
23
19
  end
24
-
25
20
  end
@@ -0,0 +1,112 @@
1
+ # This scripts finds dependencies for f90 code
2
+
3
+ raise "Need Ruby version >= 1.8, current using #{VERSION}" unless String.instance_methods.include? "match"
4
+
5
+ module Funit
6
+
7
+ class Depend
8
+
9
+ attr_reader :file_dependencies, :source_files
10
+
11
+ def initialize( searchPath = %w[ ../lib . ] )
12
+ @parsed = Array.new
13
+ @hash = build_hash_of_modules_in_files_within searchPath
14
+ @file_dependencies = Hash.new
15
+ @source_files = Array.new
16
+ end
17
+
18
+ def modules_used_in( file )
19
+ modules = IO.readlines( file ).map do |line|
20
+ $1.downcase if line.match( /^\s*use\s+(\w+)/i )
21
+ end.uniq.compact
22
+ end
23
+
24
+ def modules_defined_in( file )
25
+ modules = IO.readlines( file ).map do |line|
26
+ $1.downcase if line.match( /^\s*module\s+(\w+)/i )
27
+ end.uniq.compact
28
+ end
29
+
30
+ def build_dictionary_of_modules_in( files )
31
+ file_containing_module = Hash.new
32
+ files.each do |file|
33
+ modules_defined_in( file ).each{ |mod| file_containing_module[mod]=file }
34
+ end
35
+ file_containing_module
36
+ end
37
+
38
+ def fortran_files_within( search_path = %w[ ../lib . ] )
39
+ source = search_path.map{ |path| Dir[path+"/*.[fF]90"] }
40
+ source.flatten!.uniq!
41
+ source.delete_if{ |file| File.lstat(file).symlink? }
42
+ source.delete_if{ |file| file.match(/lmpi_module_template.F90/) }
43
+ end
44
+
45
+ def build_hash_of_modules_in_files_within( searchPath = %w[../lib .] )
46
+ build_dictionary_of_modules_in( fortran_files_within( searchPath ) )
47
+ end
48
+
49
+ def makefile_dependency_line( source )
50
+ realSource = source.sub(/PHYSICS_DUMMY/,'PHYSICS_MODULES')# What's this?
51
+ sourceNoPath = File.basename source
52
+ @source_files.push sourceNoPath.gsub(%r|^.*/|,'')
53
+ output = ''
54
+ if (File.expand_path(source) != File.expand_path(sourceNoPath))
55
+ output += sourceNoPath+ ": " + realSource + "\n"
56
+ output += "\tln -sf "+realSource+" .\n"
57
+ end
58
+ output += source.gsub(/\.(f|F)90$/, ".o").gsub(%r|^.*/|,"" ) +
59
+ ": " + source.gsub(%r|^.*/|,"" )
60
+ modules_used_in( source ).each do |use|
61
+ unless @hash[use]
62
+ unless ( use=~/f90_unix/ || use=~/nas_system/ )
63
+ $stderr.puts "Warning: unable to locate module #{use} used in #{source}." if $DEBUG
64
+ end
65
+ next
66
+ end
67
+ output = output + " \\\n " +
68
+ @hash[use].gsub(/\.(f|F)90$/, ".o").gsub(%r|^.*/|,"" )
69
+ end
70
+ output+"\n"
71
+ end
72
+
73
+ def dependencies( start )
74
+ modules = modules_used_in( start )
75
+ @parsed = @parsed || [start]
76
+ newSourceFiles = modules.collect{ |mod| @hash[mod] }.compact
77
+ makefile_dependency_line(start) +
78
+ newSourceFiles.collect do |file|
79
+ next if @parsed.include?(file)
80
+ @parsed.push file
81
+ dependencies file
82
+ end.to_s
83
+ end
84
+
85
+ def source_file_dependencies( head_f90 )
86
+ modules_head_uses = modules_used_in( head_f90 )
87
+ required_f90s = modules_head_uses.map{ |mod| @hash[mod] }.compact
88
+ @file_dependencies[head_f90] = required_f90s
89
+ required_f90s.each do |required_f90|
90
+ next if @parsed.include?(required_f90)
91
+ source_file_dependencies( required_f90 )
92
+ end
93
+ @parsed.push head_f90
94
+ end
95
+
96
+ def required_source_files( head_f90 )
97
+ @parsed.clear
98
+ source_file_dependencies( head_f90 )
99
+ sources = Array.new
100
+ while !@file_dependencies.empty? do
101
+ no_dependents_pair = @file_dependencies.detect{ |h,d| d == [] }
102
+ no_dependents = no_dependents_pair.first
103
+ sources.push no_dependents
104
+ @file_dependencies.delete(no_dependents){ |el| "#{el} not found" }
105
+ @file_dependencies.each_value{ |deps| deps.delete(no_dependents) }
106
+ end
107
+ sources
108
+ end
109
+
110
+ end # class
111
+
112
+ end # module
@@ -17,7 +17,7 @@ Fortran compiler environment variable 'F9X' not set:
17
17
  raise(errorMessage) unless @name = name
18
18
  end
19
19
 
20
- end
20
+ end # class
21
21
 
22
22
  def requestedModules(moduleNames)
23
23
  if (moduleNames.empty?)
@@ -104,8 +104,6 @@ program TestRunner
104
104
  end
105
105
 
106
106
  def compileTests testSuites
107
- require 'fortran_deps'
108
-
109
107
  puts "computing dependencies"
110
108
  dependencies = Depend.new(['.', '../LibF90', '../PHYSICS_DEPS'])
111
109
  puts "locating associated source files and sorting for compilation"
@@ -114,11 +112,10 @@ program TestRunner
114
112
  puts compile = "#{ENV['F9X']} #{ENV['F9X_LDFLAGS']} -o TestRunner \\\n #{requiredSources.join(" \\\n ")}"
115
113
 
116
114
  raise "Compile failed." unless system(compile)
117
-
118
115
  end
119
116
 
120
117
  # set some regular expressions:
121
118
  $keyword = /(begin|end)(Setup|Teardown|Test)|Is(RealEqual|Equal|False|True|EqualWithin)\(.*\)/i
122
119
  $commentLine = /^\s*!/
123
120
 
124
- end # module Funit
121
+ end # module
@@ -1,6 +1,6 @@
1
1
  $:.unshift File.join( File.dirname(__FILE__), '..', 'lib' )
2
2
  require 'test/unit'
3
- require 'fortran_deps'
3
+ require 'funit/fortran_deps'
4
4
  require 'fileutils'
5
5
 
6
6
  class TestFortranDeps < Test::Unit::TestCase
@@ -30,7 +30,7 @@ class TestFortranDeps < Test::Unit::TestCase
30
30
  File.open('externalUse.f90','w') do |f|
31
31
  f.puts "program user\nuse cantFindModule\nend program"
32
32
  end
33
- @dep = Depend.new
33
+ @dep = Funit::Depend.new
34
34
  end
35
35
 
36
36
  def test_finds_which_modules_a_source_file_uses
metadata CHANGED
@@ -3,15 +3,18 @@ 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.1
7
- date: 2006-04-05 00:00:00 -04:00
6
+ version: 0.0.2
7
+ date: 2006-04-09 00:00:00 -04:00
8
8
  summary: A Fortran Unit Testing Framework
9
9
  require_paths:
10
10
  - lib
11
11
  email: funit-support@rubyforge.org
12
12
  homepage: http://funit.rubyforge.org/
13
13
  rubyforge_project: funit
14
- description:
14
+ description: "FUnit is a unit testing framework for Fortran modules. Unit tests are written in
15
+ Fortran fragments that use a small set of testing-specific extensions. FUnit
16
+ transforms these fragments into valid Fortran code and compiles, links, and runs
17
+ them against the module under test."
15
18
  autorequire: funit
16
19
  default_executable:
17
20
  bindir: bin
@@ -29,23 +32,37 @@ cert_chain:
29
32
  authors:
30
33
  - fUnit Team
31
34
  files:
35
+ - COPYING
36
+ - Rakefile
37
+ - README
32
38
  - bin/funit
33
- - tests/tc_compile.rb
34
- - tests/tc_fortran_deps.rb
35
- - tests/tc_funit.rb
36
- - tests/tc_test_suite.rb
37
- - tests/ts_funit.rb
38
- - lib/clean
39
- - lib/fortran_deps.rb
40
- - lib/funit
41
- - lib/funit.rb
42
- - lib/mklinks
43
- - lib/funit/assertions.rb
44
- - lib/funit/functions.rb
45
- - lib/funit/test_suite.rb
46
39
  - docs/HISTORY
40
+ - docs/html
47
41
  - docs/spiel
48
42
  - docs/why
43
+ - docs/html/classes
44
+ - docs/html/created.rid
45
+ - docs/html/files
46
+ - docs/html/fr_class_index.html
47
+ - docs/html/fr_file_index.html
48
+ - docs/html/fr_method_index.html
49
+ - docs/html/index.html
50
+ - docs/html/rdoc-style.css
51
+ - docs/html/classes/Funit
52
+ - docs/html/classes/Funit.html
53
+ - docs/html/classes/Funit/Assertions.html
54
+ - docs/html/classes/Funit/Compiler.html
55
+ - docs/html/classes/Funit/Depend.html
56
+ - docs/html/classes/Funit/TestSuite.html
57
+ - docs/html/files/COPYING.html
58
+ - docs/html/files/lib
59
+ - docs/html/files/README.html
60
+ - docs/html/files/lib/funit
61
+ - docs/html/files/lib/funit_rb.html
62
+ - docs/html/files/lib/funit/assertions_rb.html
63
+ - docs/html/files/lib/funit/fortran_deps_rb.html
64
+ - docs/html/files/lib/funit/functions_rb.html
65
+ - docs/html/files/lib/funit/test_suite_rb.html
49
66
  - docs/spiel/slides.tex
50
67
  - docs/why/F90testRun
51
68
  - docs/why/F90testRun.ps
@@ -68,16 +85,50 @@ files:
68
85
  - docs/why/portrait
69
86
  - docs/why/TestRunner.f90
70
87
  - docs/why/TestRunner.f90.ps
71
- - README
72
- - LICENSE
73
- - INSTALL
88
+ - examples/CFD
89
+ - examples/StopWatch
90
+ - examples/CFD/FluxFunctions.f90
91
+ - examples/CFD/fluxfunctions.mod
92
+ - examples/CFD/FluxFunctionsMT.f90
93
+ - examples/CFD/FluxFunctionsMT.ftk
94
+ - examples/CFD/Gammas.f90
95
+ - examples/CFD/gammas.mod
96
+ - examples/CFD/GasModel.f90
97
+ - examples/CFD/gasmodel.mod
98
+ - examples/CFD/GasModelMT.f90
99
+ - examples/CFD/GasModelMT.ftk
100
+ - examples/CFD/gasmodelmt.mod
101
+ - examples/CFD/TestRunner
102
+ - examples/CFD/TestRunner.f90
103
+ - examples/StopWatch/StopWatch.f90
104
+ - examples/StopWatch/stopwatch.mod
105
+ - examples/StopWatch/StopWatchMT.f90
106
+ - examples/StopWatch/StopWatchMT.ftk
107
+ - examples/StopWatch/stopwatchmt.mod
108
+ - examples/StopWatch/TestRunner
109
+ - examples/StopWatch/TestRunner.f90
110
+ - lib/clean
111
+ - lib/funit
112
+ - lib/funit.rb
113
+ - lib/mklinks
114
+ - lib/funit/assertions.rb
115
+ - lib/funit/fortran_deps.rb
116
+ - lib/funit/functions.rb
117
+ - lib/funit/test_suite.rb
118
+ - tests/tc_compile.rb
119
+ - tests/tc_fortran_deps.rb
120
+ - tests/tc_funit.rb
121
+ - tests/tc_test_suite.rb
122
+ - tests/ts_funit.rb
74
123
  test_files:
75
124
  - tests/ts_funit.rb
76
- rdoc_options: []
125
+ rdoc_options:
126
+ - "--inline-source"
127
+ - "--main"
128
+ - README
77
129
  extra_rdoc_files:
78
130
  - README
79
- - LICENSE
80
- - INSTALL
131
+ - COPYING
81
132
  executables:
82
133
  - funit
83
134
  extensions: []