forked from ska-sa/homebrew-tap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwcslib-old.rb
97 lines (91 loc) · 3.6 KB
/
wcslib-old.rb
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'formula'
class Wcslib < Formula
url 'ftp://ftp.atnf.csiro.au/pub/software/wcslib/wcslib-4.18.tar.bz2'
homepage 'http://www.atnf.csiro.au/people/mcalabre/WCS/'
sha1 '94fd36ef6adf9c7181ba12dc0959680a6c0ea776'
option 'without-tests', 'Do not install test suite'
depends_on 'cfitsio'
depends_on 'pgplot'
depends_on :fortran
def install
ENV.deparallelize
system "./configure", "--prefix=#{prefix}",
"--with-cfitsiolib=#{HOMEBREW_PREFIX}/lib", "--with-cfitsioinc=#{HOMEBREW_PREFIX}/include",
"--with-pgplotlib=#{HOMEBREW_PREFIX}/lib", "--with-pgplotinc=#{HOMEBREW_PREFIX}/include"
system "make all"
chmod 0644, 'Fortran/test/twcstab.f'
inreplace 'Fortran/test/twcstab.f', '../C/wcstab.fits', 'wcstab.fits'
system "make tests" if not build.include? 'without-tests'
system "make install"
# Install tests by default - preserve basic directory structure as in source tree
if not build.include? 'without-tests'
mkdir_p ["#{libexec}/tests/C/output", "#{libexec}/tests/Fortran/output"]
Dir.foreach('C') do |testname|
if File.file? "C/test/#{testname}.c"
cp "C/#{testname}", "#{libexec}/tests/C/"
end
end
cp_r Dir["C/test/*.out"], "#{libexec}/tests/C/output/"
cp ['C/test/units_test','C/test/wcstab.keyrec'], "#{libexec}/tests/"
Dir.foreach('Fortran') do |testname|
if File.file? "Fortran/test/#{testname}.f"
cp "Fortran/#{testname}", "#{libexec}/tests/Fortran/"
end
end
cp_r Dir["Fortran/test/*.out"], "#{libexec}/tests/Fortran/output/"
cp 'pgsbox/pgtest', "#{libexec}/tests/" if File.file? 'pgsbox/pgtest'
cp 'pgsbox/cpgtest', "#{libexec}/tests/" if File.file? 'pgsbox/cpgtest'
cd 'C'
quiet_system 'make tofits'
Dir.foreach('test') do |keyrec|
next if not keyrec.end_with? '.keyrec'
fitsname = File.basename(keyrec, '.keyrec')
safe_system "./tofits < test/#{keyrec} > #{fitsname}.fits"
cp "#{fitsname}.fits", "#{libexec}/tests/"
end
end
end
def test
if not File.directory? "#{libexec}/tests"
opoo "No tests were installed due to --without-tests option"
else
mktemp do
cp_r Dir["#{libexec}/tests/*"], '.'
ln_s '.', 'test'
['C', 'Fortran'].each do |testdir|
Dir.foreach(testdir) do |testname|
next if ['.', '..', 'output', 'tsphdpa', 'twcshdr'].include? testname
command = "yes | #{testdir}/#{testname}"
if testname.end_with? 'tunits'
command += ' < units_test'
elsif testname.end_with? 'tcel2'
command = "echo N | " + command
end
safe_system "#{command} > #{testname}.out 2>&1"
if File.file? "#{testdir}/output/#{testname}.out"
safe_system "sed -e 's/0x[0-9a-f][0-9a-f][0-9a-f]*/0x<address>/g' #{testname}.out > generic.out"
success = cmp 'generic.out', "#{testdir}/output/#{testname}.out"
elsif File.open("#{testname}.out") {|f| f.readline.start_with? 'Testing closure'}
success = File.open("#{testname}.out") {|f| f.grep('/PASS:/')}
else
success = true
end
if success
ohai "#{testdir}/#{testname} PASS"
else
onoe "#{testdir}/#{testname} FAIL"
end
end
end
if File.file? 'pgtest'
quiet_system 'yes | ./pgtest'
ohai "pgtest PASS"
end
if File.file? 'cpgtest'
quiet_system 'yes | ./cpgtest'
ohai "cpgtest PASS"
end
end
end
end
end