Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions autotest/t006_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,61 @@ def compile_code():
makeclean=False,
makefile=True,
exe_dir=dstpth,
dryrun=False,
replace_function=replace_function)


def build_with_makefile():
if os.path.isfile('makefile'):

tepth = epth
if sys.platform == 'win32':
if sys.platform.lower() == 'win32':
tepth += '.exe'

# remove existing target
print('Removing ' + target)
os.remove(tepth)
if os.path.isfile(target):
print('Removing ' + target)
os.remove(target)

print('Removing temporary build directories')
shutil.rmtree(os.path.join('src_temp'))
shutil.rmtree(os.path.join('obj_temp'))
shutil.rmtree(os.path.join('mod_temp'))
dirs_temp = [os.path.join('src_temp'),
os.path.join('obj_temp'),
os.path.join('mod_temp')]
for d in dirs_temp:
if os.path.isdir(d):
shutil.rmtree(d)

# build MODFLOW-NWT with makefile
print('build {} with makefile'.format(target))
os.system('make')
assert os.path.isfile(tepth), \
'{} created by makefile does not exist.'.format(target)

# verify that MODFLOW-NWT was made
errmsg = '{} created by makefile does not exist.'.format(target)
assert os.path.isfile(target), errmsg
else:
print('makefile does not exist...skipping build_with_make()')
return


def clean_up():
# clean up make file
if os.path.isfile('makefile'):
print('Removing makefile and temporary build directories')
shutil.rmtree(os.path.join('obj_temp'))
os.remove('makefile')
files = ['makefile', 'makedefaults']
print('Removing makefile and temporary build directories')
for fpth in files:
if os.path.isfile(fpth):
os.remove(fpth)
dirs_temp = [os.path.join('obj_temp'),
os.path.join('mod_temp')]
for d in dirs_temp:
if os.path.isdir(d):
shutil.rmtree(d)

# clean up MODFLOW-NWT download
if os.path.isdir(mfnwtpth):
print('Removing folder ' + mfnwtpth)
shutil.rmtree(mfnwtpth)

tepth = epth
tepth = target
if sys.platform == 'win32':
tepth += '.exe'

Expand Down
68 changes: 63 additions & 5 deletions autotest/t008_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,68 @@ def compile_code():
pymake.build_program(target=target,
include_subdirs=True,
download_dir=dstpth,
replace_function=replace_function)
replace_function=replace_function,
dryrun=False,
makefile=True)


def build_with_makefile():
if os.path.isfile('makefile'):

tepth = target
if sys.platform.lower() == 'win32':
tepth += '.exe'

# remove existing target
if os.path.isfile(tepth):
print('Removing ' + target)
os.remove(tepth)

print('Removing temporary build directories')
dirs_temp = [os.path.join('src_temp'),
os.path.join('obj_temp'),
os.path.join('mod_temp')]
for d in dirs_temp:
if os.path.isdir(d):
shutil.rmtree(d)

# build MODFLOW 6 with makefile
print('build {} with makefile'.format(target))
os.system('make')

# verify that MODFLOW 6 was made
errmsg = '{} created by makefile does not exist.'.format(target)
assert os.path.isfile(tepth), errmsg

else:
print('makefile does not exist...skipping build_with_make()')
return


def clean_up():
# clean up makefile
files = ['makefile', 'makedefaults']
print('Removing makefile and temporary build directories')
for fpth in files:
if os.path.isfile(fpth):
os.remove(fpth)
dirs_temp = [os.path.join('obj_temp'),
os.path.join('mod_temp')]
for d in dirs_temp:
if os.path.isdir(d):
shutil.rmtree(d)

# clean up
print('Removing folder ' + mf6pth)
shutil.rmtree(mf6pth)

ext = ''
tepth = target
if sys.platform == 'win32':
ext = '.exe'
tepth += '.exe'

print('Removing ' + target)
os.remove(target + ext)
if os.path.isfile(tepth):
print('Removing ' + target)
os.remove(tepth)
return


Expand Down Expand Up @@ -85,17 +133,27 @@ def test_mf6():
yield run_mf6, d


def test_makefile():
build_with_makefile()


def test_clean_up():
yield clean_up


if __name__ == "__main__":
# compile MODFLOW 6
compile_code()

# get name files and simulation name
example_dirs = get_example_dirs()

# run models
for d in example_dirs:
run_mf6(d)

# build modflow 6 with a pymake generated makefile
build_with_makefile()

# clean up
clean_up()
29 changes: 29 additions & 0 deletions autotest/t011_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import print_function
import os
import sys
import shutil
import json

Expand Down Expand Up @@ -107,6 +108,33 @@ def test_usgsprograms_list_json():
return


def test_make():
# add --makefile to command line list
sys.argv.append('--makefile')

# get current directory and change to working directory
cwd = os.getcwd()
os.chdir(cpth)

# build triangle and makefile
success = True
try:
pymake.build_apps('triangle')
except:
success = False

# change to starting directory
os.chdir(cwd)

# remove --makefile from command line list
sys.argv.remove('--makefile')

# evaluate success
assert success, 'could not build triangle'

return


def test_clean_up():
shutil.rmtree(cpth)

Expand All @@ -120,4 +148,5 @@ def test_clean_up():
test_usgsprograms_load_json()
test_usgsprograms_list_json_error()
test_usgsprograms_list_json()
test_make()
test_clean_up()
Loading