[ARVADOS] created: 50d2969bdaf2fbbfbe00d35ec8339b166eee8001

Git user git at public.curoverse.com
Wed Oct 5 13:53:22 EDT 2016


        at  50d2969bdaf2fbbfbe00d35ec8339b166eee8001 (commit)


commit 50d2969bdaf2fbbfbe00d35ec8339b166eee8001
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Oct 5 13:52:23 2016 -0400

    9308: Add test for KeepTmpOutput flag.

diff --git a/sdk/go/crunchrunner/crunchrunner.go b/sdk/go/crunchrunner/crunchrunner.go
index 114c49c..8dffd45 100644
--- a/sdk/go/crunchrunner/crunchrunner.go
+++ b/sdk/go/crunchrunner/crunchrunner.go
@@ -28,7 +28,7 @@ type TaskDef struct {
 	SuccessCodes       []int             `json:"task.successCodes"`
 	PermanentFailCodes []int             `json:"task.permanentFailCodes"`
 	TemporaryFailCodes []int             `json:"task.temporaryFailCodes"`
-	keepTmpOutput      bool              `json:"task.keepTmpOutput"`
+	KeepTmpOutput      bool              `json:"task.keepTmpOutput"`
 }
 
 type Tasks struct {
@@ -114,7 +114,7 @@ func setupCommand(cmd *exec.Cmd, taskp TaskDef, outdir string, replacements map[
 			if err != nil {
 				return "", "", "", err
 			}
-			if taskp.keepTmpOutput {
+			if taskp.KeepTmpOutput {
 				// Is there an os.Copy?
 				copyFile(v, outdir+"/"+k)
 			} else {
@@ -264,7 +264,7 @@ func runner(api IArvadosClient,
 	}
 
 	var tmpdir, outdir string
-	tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUuid, taskp.keepTmpOutput)
+	tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUuid, taskp.KeepTmpOutput)
 	if err != nil {
 		return TempFail{err}
 	}
@@ -360,7 +360,7 @@ func runner(api IArvadosClient,
 
 	// Upload output directory
 	var manifest string
-	if taskp.keepTmpOutput {
+	if taskp.KeepTmpOutput {
 		manifest, err = getKeepTmp(outdir)
 	} else {
 		manifest, err = WriteTree(kc, outdir)
diff --git a/sdk/go/crunchrunner/crunchrunner_test.go b/sdk/go/crunchrunner/crunchrunner_test.go
index 9805412..f4c8193 100644
--- a/sdk/go/crunchrunner/crunchrunner_test.go
+++ b/sdk/go/crunchrunner/crunchrunner_test.go
@@ -443,3 +443,31 @@ func (s *TestSuite) TestQuoting(c *C) {
 		Task{Sequence: 0})
 	c.Check(err, IsNil)
 }
+
+func (s *TestSuite) TestKeepTmp(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	os.Setenv("TASK_KEEPMOUNT_TMP", tmpdir)
+	defer os.Setenv("TASK_KEEPMOUNT_TMP", "")
+
+	fn, err := os.Create(tmpdir + "/.arvados#collection")
+	fn.Write([]byte("{\"manifest_text\":\". unparsed 0:3:foo\\n\",\"uuid\":null}"))
+	defer fn.Close()
+
+	err = runner(ArvTestClient{c,
+		". unparsed 0:3:foo\n", true},
+		KeepTestClient{},
+		"zzzz-8i9sb-111111111111111",
+		"zzzz-ot0gb-111111111111111",
+		tmpdir,
+		"",
+		Job{Script_parameters: Tasks{[]TaskDef{{
+			Command:       []string{"echo", "foo"},
+			KeepTmpOutput: true}}}},
+		Task{Sequence: 0})
+	c.Check(err, IsNil)
+
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list