From 5c1cb4fb5aaa9e8fc036bb4673b469bb5cc347d2 Mon Sep 17 00:00:00 2001 From: embrown Date: Wed, 30 Nov 2016 16:12:32 -0800 Subject: [PATCH 1/4] Added test for script() with .py extension --- testing/vcs/CMakeLists.txt | 6 ++++++ testing/vcs/test_script_for_py.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 testing/vcs/test_script_for_py.py diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index 6065f75135..9d8608cd0a 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -1197,6 +1197,12 @@ cdat_add_test(test_vcs_textextents ${BASELINE_DIR}/test_textextents.png ) +cdat_add_test(test_script_for_py + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_script_for_py.py +) + + add_subdirectory(vtk_ui) diff --git a/testing/vcs/test_script_for_py.py b/testing/vcs/test_script_for_py.py new file mode 100644 index 0000000000..016ce3fe7b --- /dev/null +++ b/testing/vcs/test_script_for_py.py @@ -0,0 +1,15 @@ +import vcs + +list=["boxfill","meshfill","isofill","textcombined","texttable","vector"] +for obj in list: + s='' + tc='' + if obj == 'textcombined': + vcs.createtextcombined('EXAMPLE_tt', 'qa', 'EXAMPLE_tto', '7left') + tc="'EXAMPLE_tt','EXAMPLE_tto'" + code="s=vcs.get%s(%s)" % (obj, tc) + exec(code) + try: + s.script(obj+"_script.py") + except: + raise("Python script creation broke on "+obj+".script()") From d967cd6c8441699cf99e163e4d77a0ff26a808d1 Mon Sep 17 00:00:00 2001 From: embrown Date: Wed, 21 Dec 2016 15:23:27 -0800 Subject: [PATCH 2/4] Validates script() works, scriptrun() on the resultant script works, and that the object created by scriptrun() is identical to the object on which script() was called. --- testing/vcs/test_script_for_py.py | 127 +++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 13 deletions(-) diff --git a/testing/vcs/test_script_for_py.py b/testing/vcs/test_script_for_py.py index 016ce3fe7b..f92b3ebe65 100644 --- a/testing/vcs/test_script_for_py.py +++ b/testing/vcs/test_script_for_py.py @@ -1,15 +1,116 @@ -import vcs - -list=["boxfill","meshfill","isofill","textcombined","texttable","vector"] -for obj in list: - s='' - tc='' - if obj == 'textcombined': - vcs.createtextcombined('EXAMPLE_tt', 'qa', 'EXAMPLE_tto', '7left') - tc="'EXAMPLE_tt','EXAMPLE_tto'" - code="s=vcs.get%s(%s)" % (obj, tc) - exec(code) +import vcs, sys, os + +def attrCompare(old_dict, new_dict): + if old_dict.keys() != new_dict.keys(): + return (False, "keys mismatch") + for key in old_dict.keys(): + if old_dict[key] == new_dict[key]: + continue + elif type(old_dict[key]) is tuple: + l = list(old_dict[key]) + if l == new_dict[key]: + continue + else: + return (False, key + "not equal.") + return (True, "All values equal") + +# graphics method list +gms = ["boxfill", "meshfill", "isofill", "vector", "isoline", "1d", "taylordiagram", "3d_scalar", "3d_dual_scalar", + "3d_vector"] +for obj in gms: + s = vcs.creategraphicsmethod(obj, 'default', 'test_%s' % obj) + s_dict = vcs.dumpToDict(s)[0] + scr = obj + "_script.py" + try: + s.script(scr) + except: + print "Python script creation broke on " + obj + ".script()" + sys.exit(1) + else: + # script was written successfully, now test for accuracy when it's run + # remove the object, or scriptrun() will just use the same thing + vcs.removeobject(s) + try: + vcs.scriptrun(scr) # test to see that scriptrun actually runs + except: + print "Scriptrun broke on " + obj + os.remove(scr) + sys.exit(1) + else: + # script has both written and run without failure, just need to check for accuracy + try: + new_s = vcs.getgraphicsmethod(obj, "test_%s" % obj) + except: + print "Scriptrun failed: test_%s does not exist" %obj + sys.exit(1) + else: + new_s_dict = vcs.dumpToDict(new_s)[0] + comp = attrCompare(s_dict, new_s_dict) + if not comp[0]: + print "Scriptrun failed: " + comp[1] + sys.exit(1) + if os.path.exists(scr): + os.remove(scr) + + +# text objects +tt = vcs.createtexttable('test_tt') +to = vcs.createtextorientation('test_tto') +tcs = vcs.listelements('textcombined') +if len(tcs) == 0: + tc = vcs.createtext(Tt_name="testtext", Tt_source=tt.name, To_name="testtext", To_source=to.name) +else: + tc = vcs.gettext(tcs[0]) + +# other secondaries +fa = vcs.createfillarea('test_fillarea') +ma = vcs.createmarker('test_marker') +li = vcs.createline('test_line') +secondaries = [tt, to, tc, fa, ma, li] +for sec in secondaries: + scr = sec.s_name + '_script.py' + old_dict = vcs.dumpToDict(sec)[0] try: - s.script(obj+"_script.py") + sec.script(scr) except: - raise("Python script creation broke on "+obj+".script()") + print "Python script creation broke on " + sec.s_name + ".script()" + sys.exit(1) + else: + vcs.removeobject(sec) + try: + vcs.scriptrun(scr) # test to see that scriptrun actually runs + except: + print "Scriptrun broke on " + sec.s_name + os.remove(scr) + # sys.exit(1) + else: + if sec.s_name == 'To': + getfunc = vcs.gettextorientation + elif sec.s_name == 'Tt': + getfunc = vcs.gettexttable + elif sec.s_name == 'Tc': + getfunc = (vcs.gettext, "testtext", "testtext") + elif sec.s_name == 'Tm': + getfunc = vcs.getmarker + elif sec.s_name == 'Tf': + getfunc = vcs.getfillarea + else: + getfunc = vcs.getline + # script has both written and run without failure, just need to check for accuracy + try: + if type(getfunc) is tuple: + new_sec = getfunc[0](getfunc[1], getfunc[2]) + else: + new_sec = getfunc(sec.name) + except: + print "Scriptrun failed: %s does not exist" % sec.name + sys.exit(1) + else: + new_dict = vcs.dumpToDict(new_sec)[0] + comp = attrCompare(old_dict, new_dict) + if comp[0]: + print comp[1] + " for " + sec.s_name + else: + print "Scriptrun failed: " + comp[1] + if os.path.exists(scr): + os.remove(scr) From 615b425f56c4c526f1eec8aa73e35e3354e2c8cd Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Thu, 22 Dec 2016 10:25:27 -0800 Subject: [PATCH 3/4] fixed conda to use conda-forge --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b8161dda8..fabe4250fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,7 +254,7 @@ include(ExternalProject) include(cdat_pkg) # CONDA Options set(CONDA_ENVIRONMENT_NAME ${cdat_VERSION} CACHE STRING "Name of conda environment we want to build CDAT in") -set(CONDA_CHANNEL_UVCDAT uvcdat CACHE STRING "channels to use (if more than one use '-c' between channels e.g. uvcdat/label/nightly -c uvcdat)") +set(CONDA_CHANNEL_UVCDAT "conda-forge -c uvcdat" CACHE STRING "channels to use (if more than one use '-c' between channels e.g. uvcdat/label/nightly -c uvcdat)") execute_process(COMMAND "${GIT_EXECUTABLE}" symbolic-ref --short HEAD From 55853a5a0e15ee9b6870d47097ff87c497f4ebf7 Mon Sep 17 00:00:00 2001 From: embrown Date: Tue, 27 Dec 2016 08:56:44 -0800 Subject: [PATCH 4/4] Forgot calls to sys.exit(1) on failure. --- testing/vcs/test_script_for_py.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/vcs/test_script_for_py.py b/testing/vcs/test_script_for_py.py index f92b3ebe65..28ea1df823 100644 --- a/testing/vcs/test_script_for_py.py +++ b/testing/vcs/test_script_for_py.py @@ -82,7 +82,7 @@ def attrCompare(old_dict, new_dict): except: print "Scriptrun broke on " + sec.s_name os.remove(scr) - # sys.exit(1) + sys.exit(1) else: if sec.s_name == 'To': getfunc = vcs.gettextorientation @@ -112,5 +112,6 @@ def attrCompare(old_dict, new_dict): print comp[1] + " for " + sec.s_name else: print "Scriptrun failed: " + comp[1] + sys.exit(1) if os.path.exists(scr): os.remove(scr)