[PATCH] Make dotted context keys available in the environment.
Nathaniel Smith
njs at pobox.com
Mon Aug 11 18:11:59 UTC 2003
See attached.
-- Nathaniel
--
"...All of this suggests that if we wished to find a modern-day model
for British and American speech of the late eighteenth century, we could
probably do no better than Yosemite Sam."
-------------- next part --------------
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/ChangeLog qm-dots-in-context-vars/ChangeLog
--- qm-clean/ChangeLog 2003-08-10 23:44:30.000000000 -0700
+++ qm-dots-in-context-vars/ChangeLog 2003-08-11 11:09:30.000000000 -0700
@@ -1,3 +1,27 @@
+2003-08-11 Nathaniel Smith <njs at codesourcery.com>
+
+ * qm/test/classes/command.py (ExecTestBase.MakeEnvironment):
+ Replace "." with "__" when turning context keys into environment
+ variables. Document in class docstring.
+ (ExecTest.Run): Fix indentation.
+ * qm/test/doc/reference.xml: Document new handling of context
+ variables with "."s in them.
+ * tests/regress/QMTest/selftest.py: Import os.path. Add more
+ documentation.
+ (RegTest.Run): Check for a context file, and if one is found,
+ use it.
+ * tests/regress/env_context1: New directory.
+ * tests/regress/env_context1/QMTest: New directory.
+ * tests/regress/env_context1/QMTest/configuration: New file.
+ * tests/regress/env_context1/context: New file.
+ * tests/regress/env_context1/results.qmr: New file.
+ * tests/regress/env_context1/exectest_nodot.qmt: New file.
+ * tests/regress/env_context1/exectest_dot.qmt: New file.
+ * tests/regress/env_context1/shellcommandtest_nodot.qmt: New file.
+ * tests/regress/env_context1/shellcommandtest_dot.qmt: New file.
+ * tests/regress/env_context1/shellscripttest_nodot.qmt: New file.
+ * tests/regress/env_context1/shellscripttest_dot.qmt: New file.
+
2003-08-10 Nathaniel Smith <njs at codesourcery.com>
* qm/common.py (get_lib_directory): Remove.
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/qm/test/classes/command.py qm-dots-in-context-vars/qm/test/classes/command.py
--- qm-clean/qm/test/classes/command.py 2003-07-30 15:25:00.000000000 -0700
+++ qm-dots-in-context-vars/qm/test/classes/command.py 2003-08-11 11:04:35.000000000 -0700
@@ -79,7 +79,10 @@
of the environment variable is the name of the context
property, prefixed with 'QMV_'. For example, if the value
of the context property named 'target' is available in the
- environment variable 'QMV_target'.""" )),
+ environment variable 'QMV_target'. Any dots in the context
+ key are replaced by a double-underscore; e.g.,
+ "CompilerTable.c_path" will become
+ "QMV_CompilerTable__c_path".""" )),
qm.fields.IntegerField(
name="exit_code",
@@ -137,8 +140,8 @@
environment = os.environ.copy()
# Copy context variables into the environment.
for key, value in context.items():
- if "." not in key and type(value) == types.StringType:
- name = "QMV_" + key
+ if isinstance(value, str):
+ name = "QMV_" + key.replace(".", "__")
environment[name] = value
# Extract additional environment variable assignments from the
# 'Environment' field.
@@ -296,7 +299,7 @@
return
self.RunProgram(self.program,
- [ self.program ] + self.arguments,
+ [ self.program ] + self.arguments,
context, result)
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/qm/test/doc/reference.xml qm-dots-in-context-vars/qm/test/doc/reference.xml
--- qm-clean/qm/test/doc/reference.xml 2003-06-22 23:46:47.000000000 -0700
+++ qm-dots-in-context-vars/qm/test/doc/reference.xml 2003-08-11 11:03:29.000000000 -0700
@@ -1633,11 +1633,15 @@
<para><classname>command.ExecTest</classname> adds additional
environment variables automatically.</para>
- <para>In addition, every context property whose key does not
- contain a "." and whose value is a string is
- accessible as an environment variable; the name of the
+ <para>In addition, every context property whose value is a string
+ is accessible as an environment variable; the name of the
environment variable is the name of the context property,
- prefixed with "<envar>QMV_</envar>".</para>
+ prefixed with "<envar>QMV_</envar>" and with any dots
+ (".") replaced by a double underscore
+ ("__"). For example, a context variable
+ "CompilerTable.c_path" would correspond to an
+ environment variable
+ "<envar>QMV_CompilerTable__c_path</envar>".</para>
</glossdef>
</glossentry>
Binary files qm-clean/results.qmr and qm-dots-in-context-vars/results.qmr differ
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/QMTest/selftest.py qm-dots-in-context-vars/tests/regress/QMTest/selftest.py
--- qm-clean/tests/regress/QMTest/selftest.py 2003-08-07 10:05:20.000000000 -0700
+++ qm-dots-in-context-vars/tests/regress/QMTest/selftest.py 2003-08-11 10:28:22.000000000 -0700
@@ -18,6 +18,7 @@
########################################################################
import os
+import os.path
import re
import qm.executable
from qm.test.test import *
@@ -34,7 +35,13 @@
directory. Each such subdirectory is a complete test database in
itself, such that running "qmtest -D . run -O results.qmr" in that
directory should succeed, reporting all tests completed as
- expected. The test is judged to have succeeded if so."""
+ expected. The test is judged to have succeeded if so.
+
+ The context key "qmtest_path" should contain the path to the qmtest
+ executable. If the context key "qmtest_target" is defined, the
+ test database will be run using that target. If the test database
+ contains a file "context", then the test database will be run with
+ it as a context file."""
arguments = [
qm.fields.TextField(
@@ -60,6 +67,7 @@
path = self.path
results = os.path.join(path, "results.qmr")
output = os.path.join(path, "output.qmr")
+ context_file = os.path.join(path, "context")
# Sanity check the target location.
assert os.path.isdir(os.path.join(path, "QMTest"))
@@ -75,6 +83,10 @@
if context.has_key("qmtest_target"):
argv += ("-T", context["qmtest_target"])
+ # And if there is a context file, use it.
+ if os.path.exists(context_file):
+ argv += ("-C", context_file)
+
e = qm.executable.RedirectedExecutable()
status = e.Run(argv)
stdout = e.stdout
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/QMTest/configuration qm-dots-in-context-vars/tests/regress/env_context1/QMTest/configuration
--- qm-clean/tests/regress/env_context1/QMTest/configuration 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/QMTest/configuration 2003-08-11 10:36:16.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="xml_database.XMLDatabase" kind="database"/>
\ No newline at end of file
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/context qm-dots-in-context-vars/tests/regress/env_context1/context
--- qm-clean/tests/regress/env_context1/context 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/context 2003-08-11 11:07:29.000000000 -0700
@@ -0,0 +1,2 @@
+foo=foo
+foo.bar=foo.bar
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/exectest_dot.qmt qm-dots-in-context-vars/tests/regress/env_context1/exectest_dot.qmt
--- qm-clean/tests/regress/env_context1/exectest_dot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/exectest_dot.qmt 2003-08-11 10:41:19.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ExecTest" kind="test"><argument name="target_group"><text>.*</text></argument><argument name="stderr"><text/></argument><argument name="stdout"><text>foo.bar</text></argument><argument name="prerequisites"><set/></argument><argument name="stdin"><text/></argument><argument name="exit_code"><integer>0</integer></argument><argument name="environment"><set/></argument><argument name="program"><text>printenv</text></argument><argument name="arguments"><set><text>QMV_foo__bar</text></set></argument><argument name="timeout"><integer>-1</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/exectest_nodot.qmt qm-dots-in-context-vars/tests/regress/env_context1/exectest_nodot.qmt
--- qm-clean/tests/regress/env_context1/exectest_nodot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/exectest_nodot.qmt 2003-08-11 10:42:12.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ExecTest" kind="test"><argument name="target_group"><text>.*</text></argument><argument name="stderr"><text/></argument><argument name="stdout"><text>foo</text></argument><argument name="prerequisites"><set/></argument><argument name="stdin"><text/></argument><argument name="exit_code"><integer>0</integer></argument><argument name="environment"><set/></argument><argument name="program"><text>printenv</text></argument><argument name="arguments"><set><text>QMV_foo</text></set></argument><argument name="timeout"><integer>-1</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
Binary files qm-clean/tests/regress/env_context1/results.qmr and qm-dots-in-context-vars/tests/regress/env_context1/results.qmr differ
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/shellcommandtest_dot.qmt qm-dots-in-context-vars/tests/regress/env_context1/shellcommandtest_dot.qmt
--- qm-clean/tests/regress/env_context1/shellcommandtest_dot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/shellcommandtest_dot.qmt 2003-08-11 10:43:23.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ShellCommandTest" kind="test"><argument name="environment"><set/></argument><argument name="target_group"><text>.*</text></argument><argument name="command"><text>echo ${QMV_foo__bar}</text></argument><argument name="timeout"><integer>-1</integer></argument><argument name="stderr"><text/></argument><argument name="stdout"><text>foo.bar</text></argument><argument name="prerequisites"><set/></argument><argument name="stdin"><text/></argument><argument name="exit_code"><integer>0</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/shellcommandtest_nodot.qmt qm-dots-in-context-vars/tests/regress/env_context1/shellcommandtest_nodot.qmt
--- qm-clean/tests/regress/env_context1/shellcommandtest_nodot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/shellcommandtest_nodot.qmt 2003-08-11 10:42:54.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ShellCommandTest" kind="test"><argument name="environment"><set/></argument><argument name="target_group"><text>.*</text></argument><argument name="command"><text>echo ${QMV_foo}</text></argument><argument name="timeout"><integer>-1</integer></argument><argument name="stderr"><text/></argument><argument name="stdout"><text>foo</text></argument><argument name="prerequisites"><set/></argument><argument name="stdin"><text/></argument><argument name="exit_code"><integer>0</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/shellscripttest_dot.qmt qm-dots-in-context-vars/tests/regress/env_context1/shellscripttest_dot.qmt
--- qm-clean/tests/regress/env_context1/shellscripttest_dot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/shellscripttest_dot.qmt 2003-08-11 10:44:29.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ShellScriptTest" kind="test"><argument name="stdin"><text/></argument><argument name="stdout"><text>foo.bar</text></argument><argument name="stderr"><text/></argument><argument name="script"><text>echo ${QMV_foo__bar}</text></argument><argument name="prerequisites"><set/></argument><argument name="target_group"><text>.*</text></argument><argument name="exit_code"><integer>0</integer></argument><argument name="environment"><set/></argument><argument name="arguments"><set/></argument><argument name="timeout"><integer>-1</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=thread_target --exclude=process_target qm-clean/tests/regress/env_context1/shellscripttest_nodot.qmt qm-dots-in-context-vars/tests/regress/env_context1/shellscripttest_nodot.qmt
--- qm-clean/tests/regress/env_context1/shellscripttest_nodot.qmt 1969-12-31 16:00:00.000000000 -0800
+++ qm-dots-in-context-vars/tests/regress/env_context1/shellscripttest_nodot.qmt 2003-08-11 10:43:55.000000000 -0700
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<!DOCTYPE extension
+ PUBLIC '-//Software Carpentry//QMTest Extension V0.1//EN'
+ 'http://www.software-carpentry.com/qm/xml/extension'>
+<extension class="command.ShellScriptTest" kind="test"><argument name="stdin"><text/></argument><argument name="stdout"><text>foo</text></argument><argument name="stderr"><text/></argument><argument name="script"><text>echo ${QMV_foo}</text></argument><argument name="prerequisites"><set/></argument><argument name="target_group"><text>.*</text></argument><argument name="exit_code"><integer>0</integer></argument><argument name="environment"><set/></argument><argument name="arguments"><set/></argument><argument name="timeout"><integer>-1</integer></argument><argument name="resources"><set/></argument></extension>
\ No newline at end of file
More information about the qmtest
mailing list