Merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module

Proposed by Nicolae Brinza
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/process-2
Merge into: lp:zorba/process-module
Diff against target: 582 lines (+274/-57)
17 files modified
src/com/zorba-xquery/www/modules/CMakeLists.txt (+1/-1)
src/com/zorba-xquery/www/modules/process.xq (+107/-11)
src/com/zorba-xquery/www/modules/process.xq.src/process.cpp (+115/-33)
src/com/zorba-xquery/www/modules/process.xq.src/process.h (+7/-4)
test/ExpQueryResults/process2-01.xml.res (+1/-0)
test/ExpQueryResults/process2-02.xml.res (+1/-0)
test/ExpQueryResults/process2-03.xml.res (+1/-0)
test/ExpQueryResults/process2-04.xml.res (+1/-0)
test/ExpQueryResults/process2-05.xml.res (+1/-0)
test/ExpQueryResults/process2-06.xml.res (+1/-0)
test/Queries/process.xq (+8/-8)
test/Queries/process2-01.xq (+5/-0)
test/Queries/process2-02.xq (+5/-0)
test/Queries/process2-03.xq (+5/-0)
test/Queries/process2-04.xq (+6/-0)
test/Queries/process2-05.xq (+5/-0)
test/Queries/process2-06.xq (+4/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/process-2
Reviewer Review Type Date Requested Status
Nicolae Brinza Approve
Matthias Brantner Pending
Review via email: mp+164354@code.launchpad.net

Commit message

Version 2.0 of the process module, allows running executables directly, without invoking bash/cmd.exe

Description of the change

Version 2.0 of the process module, allows running executables directly, without invoking bash/cmd.exe

To post a comment you must log in.
Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T12-29-40.913Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T13-03-41.447Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T13-34-44.754Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T13-53-40.588Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T14-27-39.824Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/process-2 into lp:zorba/process-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job process-2-2013-05-17T14-42-40.749Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

lp:~zorba-coders/zorba/process-2 updated
40. By Nicolae Brinza

Fixed the build

41. By Nicolae Brinza

Updated documentation

42. By Nicolae Brinza

Addressed review comments: documentation fixes; brought back version 1.0 of the module, both 1.0 and 2.0 are avialable now

43. By Nicolae Brinza

Removed unused function

44. By Nicolae Brinza

The child fork()'ed process will now call abort() instead of exit() in order to avoid static object deallocation

45. By Nicolae Brinza

Improved comments; changed process module version from XQuery to JSONiq; removed xs: prefixes

46. By Nicolae Brinza

Moved the ver2.0 process module to the zorba.io ver1.0 namespace

47. By Matthias Brantner

moved files

48. By Matthias Brantner

fixed module naming and versioning

49. By Matthias Brantner

improve documentation

50. By Nicolae Brinza

Removed unecessary includes

51. By Nicolae Brinza

Changed module's errors to the new modules guidelines; Potential fix for execvpe() on Macs

52. By Nicolae Brinza

Merged with process module trunk

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/zorba-xquery/www/modules/CMakeLists.txt'
2--- src/com/zorba-xquery/www/modules/CMakeLists.txt 2011-07-01 09:24:09 +0000
3+++ src/com/zorba-xquery/www/modules/CMakeLists.txt 2013-05-17 14:51:23 +0000
4@@ -12,4 +12,4 @@
5 # See the License for the specific language governing permissions and
6 # limitations under the License.
7
8-DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/process" VERSION 1.0 FILE "process.xq")
9+DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/process" VERSION 2.0 FILE "process.xq")
10
11=== modified file 'src/com/zorba-xquery/www/modules/process.xq'
12--- src/com/zorba-xquery/www/modules/process.xq 2012-12-06 02:13:28 +0000
13+++ src/com/zorba-xquery/www/modules/process.xq 2013-05-17 14:51:23 +0000
14@@ -28,14 +28,17 @@
15 :
16 : Potential result:
17 : <pre class="ace-static" ace-mode="xquery"><![CDATA[
18- : <result xmlns="http://www.zorba-xquery.com/modules/process">
19- : <stdout>myfile.txt</stout>
20- : <stderr/>
21- : <exit-code>0</exit-code>
22- : </result>
23+ : {
24+ : "exit-code": 0,
25+ : "stdout": "myfile.txt",
26+ : "stderr": ""
27+ : }
28 : ]]></pre>
29 :
30- : @author Cezar Andrei
31+ : The exec-command() set of functions allows execution of commands through the operating
32+ : system's command line interpreter, such as "sh" on Linux or "cmd.exe" on Windows.
33+ :
34+ : @author Cezar Andrei, Nicolae Brinza
35 : @project Zorba/IO/Process
36 :
37 :)
38@@ -44,7 +47,100 @@
39 declare namespace an = "http://www.zorba-xquery.com/annotations";
40
41 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
42-declare option ver:module-version "1.0";
43+declare option ver:module-version "2.0";
44+
45+
46+(:~
47+ : Executes the specified program in a separate process.
48+ : This function does not allow arguments to be passed to
49+ : the command. The $filename parameter can contain the full path to the
50+ : executable. On Linux systems, if the specified filename does not contain
51+ : a slash "/", the function duplicates the actions of the shell in searching
52+ : for an executable file. The file is sought in the colon-separated list of
53+ : directory pathnames specified in the PATH environment variable. If this
54+ : variable isn't defined, the path list defaults to the current directory
55+ : followed by the list of directories returned by the operating system.
56+ :
57+ : @param $filename the name of program to be executed
58+ :
59+ : @return the result of the execution as an object as
60+ : shown in the documentation of this module. The exit-code
61+ : returns the exit code of the child process.
62+ : For POSIX compliant platforms: returns the program exit code. If the program is
63+ : terminated or stopped: 128 + termination signal code.
64+ : For Windows platforms: returns the return value of the program or the exit
65+ : or terminate process specified value.
66+ :
67+ : @error process:PROC01 if an error occurred while communicating
68+ : with the executed process.
69+ :)
70+declare %an:sequential function process:exec(
71+ $filename as xs:string
72+) as object() external;
73+
74+(:~
75+ : Executes the specified program in a separate process.
76+ : The $filename parameter can contain the full path to the
77+ : executable. On Linux systems, if the specified filename does not contain
78+ : a slash "/", the function duplicates the actions of the shell in searching
79+ : for an executable file. The file is sought in the colon-separated list of
80+ : directory pathnames specified in the PATH environment variable. If this
81+ : variable isn't defined, the path list defaults to the current directory
82+ : followed by the list of directories returned by the operating system.
83+ : The $args parameters will be passed to the executable file as arguments.
84+ :
85+ : @param $filename the name of program to be executed
86+ : @param $args arguments to be passed to the executable
87+ :
88+ : @return the result of the execution as an object as
89+ : shown in the documentation of this module. The exit-code
90+ : returns the exit code of the child process.
91+ : For POSIX compliant platforms: returns the program exit code. If the program is
92+ : terminated or stopped: 128 + termination signal code.
93+ : For Windows platforms: returns the return value of the program or the exit
94+ : or terminate process specified value.
95+ :
96+ : @error process:PROC01 if an error occurred while communicating
97+ : with the executed process.
98+ :)
99+declare %an:sequential function process:exec(
100+ $filename as xs:string,
101+ $args as xs:string*
102+) as object() external;
103+
104+(:~
105+ : Executes the specified program in a separate process.
106+ : The $filename parameter can contain the full path to the
107+ : executable. On Linux systems, if the specified filename does not contain
108+ : a slash "/", the function duplicates the actions of the shell in searching
109+ : for an executable file. The file is sought in the colon-separated list of
110+ : directory pathnames specified in the PATH environment variable. If this
111+ : variable isn't defined, the path list defaults to the current directory
112+ : followed by the list of directories returned by the operating system.
113+ : The $args parameters will be passed to the executable file as arguments.
114+ : The $env allows defining and passing environment variables to the target
115+ : process. They should be in the form "ENVVAR=value" where "ENVVAR" is the
116+ : name of the environment variable and "value' is the string value to set it to.
117+ :
118+ : @param $filename the name of program to be executed
119+ : @param $args arguments to be passed to the executable
120+ :
121+ : @return the result of the execution as an object as
122+ : shown in the documentation of this module. The exit-code
123+ : returns the exit code of the child process.
124+ : For POSIX compliant platforms: returns the program exit code. If the program is
125+ : terminated or stopped: 128 + termination signal code.
126+ : For Windows platforms: returns the return value of the program or the exit
127+ : or terminate process specified value.
128+ :
129+ : @error process:PROC01 if an error occurred while communicating
130+ : with the executed process.
131+ :)
132+declare %an:sequential function process:exec(
133+ $filename as xs:string,
134+ $args as xs:string*,
135+ $env as xs:string*
136+) as object() external;
137
138 (:~
139 : Executes the specified string command in a separate process.
140@@ -64,9 +160,9 @@
141 : @error process:PROC01 if an error occurred while communicating
142 : with the executed process.
143 :)
144-declare %an:sequential function process:exec(
145+declare %an:sequential function process:exec-command(
146 $cmd as xs:string
147-) as element(process:result) external;
148+) as object() external;
149
150 (:~
151 : Executes the specified string command in a separate process.
152@@ -87,7 +183,7 @@
153 : @error process:PROC01 if an error occurred while communicating
154 : with the executed process.
155 :)
156-declare %an:sequential function process:exec(
157+declare %an:sequential function process:exec-command(
158 $cmd as xs:string,
159 $args as xs:string*
160-) as element(process:result) external;
161+) as object() external;
162
163=== modified file 'src/com/zorba-xquery/www/modules/process.xq.src/process.cpp'
164--- src/com/zorba-xquery/www/modules/process.xq.src/process.cpp 2012-12-05 17:29:38 +0000
165+++ src/com/zorba-xquery/www/modules/process.xq.src/process.cpp 2013-05-17 14:51:23 +0000
166@@ -25,7 +25,6 @@
167
168 #ifdef WIN32
169 # include <windows.h>
170-
171 # ifndef NDEBUG
172 # define _CRTDBG_MAP_ALLOC
173 # include <stdlib.h>
174@@ -49,6 +48,20 @@
175
176 #include "process.h"
177
178+// Provde the execvpe() function since some platforms don't have it
179+#ifndef WIN32
180+int execvpe(const char *program, char **argv, char **envp)
181+{
182+ char **saved = environ;
183+ int rc;
184+ environ = envp;
185+ rc = execvp(program, argv);
186+ environ = saved;
187+ return rc;
188+}
189+#endif
190+
191+
192 namespace zorba {
193 namespace processmodule {
194
195@@ -100,6 +113,28 @@
196 aFactory->createTextNode(lExitCode, lExitCodeString.str());
197 }
198
199+void create_result_object(
200+ zorba::Item& aResult,
201+ const std::string& aStandardOut,
202+ const std::string& aErrorOut,
203+ int aExitCode,
204+ zorba::ItemFactory* aFactory)
205+{
206+ std::vector<std::pair<zorba::Item,zorba::Item> > pairs;
207+
208+ pairs.push_back(std::pair<zorba::Item,zorba::Item>(aFactory->createString("exit-code"), aFactory->createInt(aExitCode)));
209+ pairs.push_back(std::pair<zorba::Item,zorba::Item>(aFactory->createString("stdout"), aFactory->createString(aStandardOut)));
210+ pairs.push_back(std::pair<zorba::Item,zorba::Item>(aFactory->createString("stderr"), aFactory->createString(aErrorOut)));
211+
212+ aResult = aFactory->createJSONObject(pairs);
213+}
214+
215+void free_char_vector(std::vector<char*> argv)
216+{
217+ for (unsigned int i=0; i<argv.size(); i++)
218+ free(argv[i]);
219+}
220+
221 #ifdef WIN32
222
223 /***********************************************
224@@ -307,7 +342,7 @@
225 #define READ 0
226 #define WRITE 1
227
228-pid_t zorba_popen(const char *command, int *infp, int *outfp, int *errfp)
229+pid_t exec_helper(int *infp, int *outfp, int *errfp, const char *command, char* argv[], char* env[])
230 {
231 int p_stdin[2];
232 int p_stdout[2];
233@@ -332,7 +367,13 @@
234 close(p_stderr[READ]);
235 dup2(p_stderr[WRITE], 2); // duplicate stderr
236
237- execl("/bin/sh", "sh", "-c", command, NULL);
238+ if (command)
239+ execl("/bin/sh", "sh", "-c", command, NULL);
240+ else if (env == NULL)
241+ execvp(argv[0], argv);
242+ else
243+ execvpe(argv[0], argv, env);
244+
245 perror("execl"); // output the result to standard error
246 exit(errno);
247 }
248@@ -358,10 +399,23 @@
249
250 return pid;
251 }
252+
253 #endif
254
255+
256 /******************************************************************************
257 *****************************************************************************/
258+String ExecFunction::getOneStringArgument (const Arguments_t& aArgs, int aPos) const
259+{
260+ Item lItem;
261+ Iterator_t args_iter = aArgs[aPos]->getIterator();
262+ args_iter->open();
263+ args_iter->next(lItem);
264+ zorba::String lTmpString = lItem.getStringValue();
265+ args_iter->close();
266+ return lTmpString;
267+}
268+
269 zorba::ItemSequence_t
270 ExecFunction::evaluate(
271 const Arguments_t& aArgs,
272@@ -370,6 +424,7 @@
273 {
274 std::string lCommand;
275 std::vector<std::string> lArgs;
276+ std::vector<std::string> lEnv;
277 int exit_code = 0;
278
279 lCommand = getOneStringArgument(aArgs, 0).c_str();
280@@ -379,12 +434,20 @@
281 zorba::Item lArg;
282 Iterator_t arg1_iter = aArgs[1]->getIterator();
283 arg1_iter->open();
284- while (arg1_iter->next(lArg))
285- {
286+ while (arg1_iter->next(lArg))
287 lArgs.push_back(lArg.getStringValue().c_str());
288- }
289 arg1_iter->close();
290 }
291+
292+ if (aArgs.size() > 2)
293+ {
294+ zorba::Item lArg;
295+ Iterator_t arg1_iter = aArgs[2]->getIterator();
296+ arg1_iter->open();
297+ while (arg1_iter->next(lArg))
298+ lEnv.push_back(lArg.getStringValue().c_str());
299+ arg1_iter->close();
300+ }
301
302 std::ostringstream lTmp;
303
304@@ -432,18 +495,38 @@
305 int errfp;
306 int status;
307 pid_t pid;
308+
309+ std::vector<char*> argv(lArgs.size()+2, NULL);
310+ std::vector<char*> env(lEnv.size()+1, NULL);
311
312- pid = zorba_popen(lTmp.str().c_str(), NULL, &outfp, &errfp);
313- if ( pid == -1 )
314- {
315- std::stringstream lErrorMsg;
316- lErrorMsg << "Failed to execute the command (" << pid << ")";
317- Item lQName = ProcessModule::getItemFactory()->createQName(
318- "http://www.zorba-xquery.com/modules/process", "PROC01");
319- throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
320- }
321- else
322- {
323+ try
324+ {
325+ if (theIsExecProgram)
326+ {
327+ argv[0] = strdup(lCommand.c_str());
328+ for (unsigned int i=0; i<lArgs.size(); i++)
329+ argv[i+1] = strdup(lArgs[i].c_str());
330+
331+ for (unsigned int i=0; i<lEnv.size(); i++)
332+ env[i] = strdup(lEnv[i].c_str());
333+
334+ pid = exec_helper(NULL, &outfp, &errfp, NULL, argv.data(), lEnv.size() ? env.data() : NULL);
335+ }
336+ else
337+ {
338+ pid = exec_helper(NULL, &outfp, &errfp, lTmp.str().c_str(), argv.data(), NULL);
339+ }
340+
341+ if ( pid == -1 )
342+ {
343+ std::stringstream lErrorMsg;
344+ lErrorMsg << "Failed to execute the command (" << pid << ")";
345+ Item lQName = ProcessModule::getItemFactory()->createQName(
346+ "http://www.zorba-xquery.com/modules/process", "PROC01");
347+ throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
348+ return NULL;
349+ }
350+
351 char lBuf[PATH_MAX];
352 ssize_t length = 0;
353 while ( (length=read(outfp, lBuf, PATH_MAX)) > 0 )
354@@ -504,28 +587,23 @@
355 }
356
357 //std::cout << " exit_code : " << exit_code << std::endl; std::cout.flush();
358-
359+ free_char_vector(argv);
360+ free_char_vector(env);
361+ }
362+ catch (...)
363+ {
364+ free_char_vector(argv);
365+ free_char_vector(env);
366+ throw;
367 }
368 #endif // WIN32
369
370 zorba::Item lResult;
371- create_result_node(lResult, lStdout.str(), lStderr.str(), exit_code,
372- theModule->getItemFactory());
373-
374+ create_result_object(lResult, lStdout.str(), lStderr.str(), exit_code,
375+ theModule->getItemFactory());
376 return zorba::ItemSequence_t(new zorba::SingletonItemSequence(lResult));
377 }
378
379-String ExecFunction::getOneStringArgument (const Arguments_t& aArgs, int aPos)
380- const
381-{
382- Item lItem;
383- Iterator_t args_iter = aArgs[aPos]->getIterator();
384- args_iter->open();
385- args_iter->next(lItem);
386- zorba::String lTmpString = lItem.getStringValue();
387- args_iter->close();
388- return lTmpString;
389-}
390
391 /******************************************************************************
392 *****************************************************************************/
393@@ -545,10 +623,14 @@
394 zorba::ExternalFunction*& lFunc = theFunctions[aLocalname];
395 if (lFind == theFunctions.end())
396 {
397- if (!aLocalname.compare("exec"))
398+ if (aLocalname.compare("exec-command") == 0)
399 {
400 lFunc = new ExecFunction(this);
401 }
402+ else if (aLocalname.compare("exec") == 0)
403+ {
404+ lFunc = new ExecFunction(this, true);
405+ }
406 }
407 return lFunc;
408 }
409
410=== modified file 'src/com/zorba-xquery/www/modules/process.xq.src/process.h'
411--- src/com/zorba-xquery/www/modules/process.xq.src/process.h 2012-07-21 01:09:37 +0000
412+++ src/com/zorba-xquery/www/modules/process.xq.src/process.h 2013-05-17 14:51:23 +0000
413@@ -74,12 +74,13 @@
414 class ExecFunction : public ContextualExternalFunction
415 {
416 public:
417- ExecFunction(const ProcessModule* aModule) : theModule(aModule) {}
418+ ExecFunction(const ProcessModule* aModule, bool aExecProgram = false)
419+ : theModule(aModule), theIsExecProgram(aExecProgram) {}
420
421 virtual ~ExecFunction() {}
422
423 virtual zorba::String
424- getLocalName() const { return "exec"; }
425+ getLocalName() const { if (theIsExecProgram) return "exec"; else return "exec-command"; }
426
427 virtual zorba::ItemSequence_t
428 evaluate(const Arguments_t&,
429@@ -93,12 +94,14 @@
430
431 protected:
432 const ProcessModule* theModule;
433+
434+ bool theIsExecProgram; // if set to true, will use the execvpe() version of the system function
435+ // if set to false, will build a command string and pass it to
436+ // either "bash" or "cmd.exe" (through execl() on Linux)
437
438 String getOneStringArgument (const Arguments_t& aArgs, int index) const;
439 };
440
441-
442-
443 } /* namespace processmodule */
444 } /* namespace zorba */
445
446
447=== added file 'test/ExpQueryResults/process2-01.xml.res'
448--- test/ExpQueryResults/process2-01.xml.res 1970-01-01 00:00:00 +0000
449+++ test/ExpQueryResults/process2-01.xml.res 2013-05-17 14:51:23 +0000
450@@ -0,0 +1,1 @@
451+true
452\ No newline at end of file
453
454=== added file 'test/ExpQueryResults/process2-02.xml.res'
455--- test/ExpQueryResults/process2-02.xml.res 1970-01-01 00:00:00 +0000
456+++ test/ExpQueryResults/process2-02.xml.res 2013-05-17 14:51:23 +0000
457@@ -0,0 +1,1 @@
458+true
459\ No newline at end of file
460
461=== added file 'test/ExpQueryResults/process2-03.xml.res'
462--- test/ExpQueryResults/process2-03.xml.res 1970-01-01 00:00:00 +0000
463+++ test/ExpQueryResults/process2-03.xml.res 2013-05-17 14:51:23 +0000
464@@ -0,0 +1,1 @@
465+true
466\ No newline at end of file
467
468=== added file 'test/ExpQueryResults/process2-04.xml.res'
469--- test/ExpQueryResults/process2-04.xml.res 1970-01-01 00:00:00 +0000
470+++ test/ExpQueryResults/process2-04.xml.res 2013-05-17 14:51:23 +0000
471@@ -0,0 +1,1 @@
472+true
473\ No newline at end of file
474
475=== added file 'test/ExpQueryResults/process2-05.xml.res'
476--- test/ExpQueryResults/process2-05.xml.res 1970-01-01 00:00:00 +0000
477+++ test/ExpQueryResults/process2-05.xml.res 2013-05-17 14:51:23 +0000
478@@ -0,0 +1,1 @@
479+true
480\ No newline at end of file
481
482=== added file 'test/ExpQueryResults/process2-06.xml.res'
483--- test/ExpQueryResults/process2-06.xml.res 1970-01-01 00:00:00 +0000
484+++ test/ExpQueryResults/process2-06.xml.res 2013-05-17 14:51:23 +0000
485@@ -0,0 +1,1 @@
486+true
487\ No newline at end of file
488
489=== modified file 'test/Queries/process.xq'
490--- test/Queries/process.xq 2011-08-13 00:08:53 +0000
491+++ test/Queries/process.xq 2013-05-17 14:51:23 +0000
492@@ -2,22 +2,22 @@
493
494
495 {
496- variable $stdOutTest := proc:exec("echo","hello world") ;
497- variable $stdErrTest := proc:exec("echo","Ooops. an error. 1>&amp;2");
498- variable $stdOutWinTest := proc:exec("cmd", ("/c", "echo","hello world")) ;
499- variable $stdErrWinTest := proc:exec("cmd", ("/c", "echo","Ooops. an error. 1>&amp;2"));
500+ variable $stdOutTest := proc:exec-command("echo","hello world") ;
501+ variable $stdErrTest := proc:exec-command("echo","Ooops. an error. 1>&amp;2");
502+ variable $stdOutWinTest := proc:exec-command("cmd", ("/c", "echo","hello world")) ;
503+ variable $stdErrWinTest := proc:exec-command("cmd", ("/c", "echo","Ooops. an error. 1>&amp;2"));
504
505 let $result :=
506 <result>
507- <out>{normalize-space(data($stdOutTest/proc:stdout))}</out>
508- <err>{normalize-space(data($stdErrTest/proc:stderr))}</err>
509+ <out>{normalize-space(data($stdOutTest("stdout")))}</out>
510+ <err>{normalize-space(data($stdErrTest("stderr")))}</err>
511 </result>
512 return
513 if (contains($result/err/text(),"is not recognized as an internal or external command"))
514 then
515 <result>
516- <out>{normalize-space(data($stdOutWinTest/proc:stdout))}</out>
517- <err>{normalize-space(data($stdErrWinTest/proc:stderr))}</err>
518+ <out>{normalize-space(data($stdOutWinTest("stdout")))}</out>
519+ <err>{normalize-space(data($stdErrWinTest("stderr")))}</err>
520 </result>
521 else
522 $result
523
524=== added file 'test/Queries/process2-01.xq'
525--- test/Queries/process2-01.xq 1970-01-01 00:00:00 +0000
526+++ test/Queries/process2-01.xq 2013-05-17 14:51:23 +0000
527@@ -0,0 +1,5 @@
528+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
529+
530+let $result := proc:exec("echo")
531+return $result("stdout") eq "
532+"
533
534=== added file 'test/Queries/process2-02.xq'
535--- test/Queries/process2-02.xq 1970-01-01 00:00:00 +0000
536+++ test/Queries/process2-02.xq 2013-05-17 14:51:23 +0000
537@@ -0,0 +1,5 @@
538+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
539+
540+let $result := proc:exec("echo",("hello","world"))
541+return $result("stdout") eq "hello world
542+"
543
544=== added file 'test/Queries/process2-03.xq'
545--- test/Queries/process2-03.xq 1970-01-01 00:00:00 +0000
546+++ test/Queries/process2-03.xq 2013-05-17 14:51:23 +0000
547@@ -0,0 +1,5 @@
548+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
549+
550+let $result := proc:exec("printenv",("TEST_ENV_VAR"),"TEST_ENV_VAR=foo")
551+return $result("stdout") eq "foo
552+"
553
554=== added file 'test/Queries/process2-04.xq'
555--- test/Queries/process2-04.xq 1970-01-01 00:00:00 +0000
556+++ test/Queries/process2-04.xq 2013-05-17 14:51:23 +0000
557@@ -0,0 +1,6 @@
558+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
559+
560+let $result := proc:exec("printenv",("TEST_ENV_VAR","VAR2"),("TEST_ENV_VAR=foo","VAR2=bar"))
561+return $result("stdout") eq "foo
562+bar
563+"
564
565=== added file 'test/Queries/process2-05.xq'
566--- test/Queries/process2-05.xq 1970-01-01 00:00:00 +0000
567+++ test/Queries/process2-05.xq 2013-05-17 14:51:23 +0000
568@@ -0,0 +1,5 @@
569+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
570+
571+let $result := proc:exec("echo","{}[]()()''~!@#$%^&amp;*_-+|<>/?,.")
572+return $result("stdout") eq "{}[]()()''~!@#$%^&amp;*_-+|<>/?,.
573+"
574
575=== added file 'test/Queries/process2-06.xq'
576--- test/Queries/process2-06.xq 1970-01-01 00:00:00 +0000
577+++ test/Queries/process2-06.xq 2013-05-17 14:51:23 +0000
578@@ -0,0 +1,4 @@
579+import module namespace proc = "http://www.zorba-xquery.com/modules/process";
580+
581+let $result := proc:exec("this_executable_does_not_exist")
582+return $result("exit-code") ne 0

Subscribers

People subscribed via source and target branches

to all changes: