OSDN Git Service

[TEST] eos.toExecString() v0.3.0p0037
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Wed, 3 Feb 2016 21:55:38 +0000 (06:55 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Wed, 3 Feb 2016 21:55:38 +0000 (06:55 +0900)
server/class/Eos.js
test/mocha/Eos.test.js

index a7fe1f0..7840134 100644 (file)
@@ -201,10 +201,19 @@ function validate(command, options, workspaceId) {
  * @param options
  * @returns {string}
  */
-function toExecString(command, options) {
-    var ocf = require(__dirname + '/../../user-specific-files/OptionControlFile/commands/' + command); // Array
+function toExecString(command, options, workspaceId) {
+    var ocf = ocfReference[command]; // Array
     var finalOptions = {};
     var execStr = command + ' ';
+    var ocfObj = {};
+    ocf.forEach(function(o) {
+        ocfObj[o.option] = o;
+    });
+
+
+    if(workspaceId === "1f83f620-c1ed-11e5-9657-7942989daa00") { // root
+        var root = __dirname + '/../../user-specific-files/workspace/';
+    }
 
     // set default parameters
     ocf.forEach(function(o) {
@@ -222,7 +231,16 @@ function toExecString(command, options) {
 
     // set user setting parameters
     options.forEach(function(o) {
-        finalOptions[o.name] = o.arguments;
+        var s = [];
+        var outRegExp = /out|append/;
+        o.arguments.forEach(function(arg, i) {
+            if(ocfObj[o.name].arg[i].formType === 'select' || outRegExp.test(ocfObj[o.name].arg[i].argType)) {
+                s.push(root+arg);
+            } else {
+                s.push(arg);
+            }
+        });
+        finalOptions[o.name] = s;
     });
 
     // set execution string
index 0ec03a7..ceaefdc 100644 (file)
@@ -88,8 +88,8 @@
 
         describe(test2, function() {
             it('should return true when all options is proper.', function() {
-                var result = eos.toExecString('dcdFilePrint', [{name: '-r', arguments: [1,2,3]}, { name: '-i', arguments: ['file1.txt']}, { name: '-o', arguments: ['file3.txt']} ]);
-                expect(result).to.equal('dcdFilePrint -r 1 2 3 -s 10 -e 100 -d 10 -m 0 -i file1.txt -o file3.txt');
+                var result = eos.toExecString('dcdFilePrint', [{name: '-r', arguments: [1,2,3]}, { name: '-i', arguments: ['file1.txt']}, { name: '-o', arguments: ['file3.txt']} ], "1f83f620-c1ed-11e5-9657-7942989daa00");
+                expect(result).to.equal('dcdFilePrint -r 1 2 3 -s 10 -e 100 -d 10 -m 0 -i /Users/Takafumi/zephyr/server/class/../../user-specific-files/workspace/file1.txt -o /Users/Takafumi/zephyr/server/class/../../user-specific-files/workspace/file3.txt');
             });
         });