summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-30 02:50:50 +0700
committerShulhan <ms@kilabit.info>2023-12-01 13:17:30 +0700
commitcf9fdc1387b7cf33f16fe95ef4bef55c9c008f80 (patch)
tree564f94d18e6eb138d7c3b70621bca4f2e3a1f792
parentfa3683edd2d986a26de85479b8a1c2535d069c15 (diff)
downloadawwan-cf9fdc1387b7cf33f16fe95ef4bef55c9c008f80.tar.xz
all: move wrapping BEGIN and END outside of session
-rw-r--r--awwan.go4
-rw-r--r--session.go6
-rw-r--r--testdata/http_server/execute/local_test.data2
-rw-r--r--testdata/local/local_encrypted.data4
-rw-r--r--testdata/local/local_test.data2
-rw-r--r--testdata/play/awwanssh.test/play_test.data2
6 files changed, 9 insertions, 11 deletions
diff --git a/awwan.go b/awwan.go
index 1b769bb..796eefe 100644
--- a/awwan.go
+++ b/awwan.go
@@ -314,6 +314,7 @@ func (aww *Awwan) Local(req *ExecRequest) (err error) {
goto out
}
+ req.mlog.Outf(`=== BEGIN: %s %s %s`, req.Mode, req.Script, req.LineRange)
for _, pos = range req.lineRange.list {
err = ses.executeRequires(req, pos)
if err != nil {
@@ -325,6 +326,7 @@ func (aww *Awwan) Local(req *ExecRequest) (err error) {
goto out
}
}
+ req.mlog.Outf(`=== END: %s %s %s`, req.Mode, req.Script, req.LineRange)
out:
if ses != nil {
var errRemove = os.RemoveAll(ses.dirTmp)
@@ -389,6 +391,7 @@ func (aww *Awwan) Play(req *ExecRequest) (err error) {
goto out
}
+ req.mlog.Outf(`=== BEGIN: %s %s %s`, req.Mode, req.Script, req.LineRange)
for _, pos = range req.lineRange.list {
err = ses.executeRequires(req, pos)
if err != nil {
@@ -400,6 +403,7 @@ func (aww *Awwan) Play(req *ExecRequest) (err error) {
goto out
}
}
+ req.mlog.Outf(`=== END: %s %s %s`, req.Mode, req.Script, req.LineRange)
out:
if ses != nil && ses.sshc != nil {
var errRemove = ses.sshc.rmdirAll(ses.sshc.dirTmp)
diff --git a/session.go b/session.go
index d592a94..8a1c323 100644
--- a/session.go
+++ b/session.go
@@ -443,8 +443,6 @@ func (ses *Session) executeScriptOnLocal(req *ExecRequest, pos linePosition) (er
pos.end = max - 1
}
- req.mlog.Outf(`=== BEGIN: %s %s %s`, req.Mode, req.Script, req.LineRange)
-
for x := pos.start; x <= pos.end; x++ {
stmt := req.script.stmts[x]
if stmt == nil {
@@ -476,7 +474,6 @@ func (ses *Session) executeScriptOnLocal(req *ExecRequest, pos linePosition) (er
return err
}
}
- req.mlog.Outf(`=== END`)
return nil
}
@@ -489,8 +486,6 @@ func (ses *Session) executeScriptOnRemote(req *ExecRequest, pos linePosition) (e
pos.end = max - 1
}
- req.mlog.Outf(`=== BEGIN: %s %s %s`, req.Mode, req.Script, req.LineRange)
-
for x := pos.start; x <= pos.end; x++ {
stmt := req.script.stmts[x]
if stmt == nil {
@@ -523,7 +518,6 @@ func (ses *Session) executeScriptOnRemote(req *ExecRequest, pos linePosition) (e
return err
}
}
- req.mlog.Outf(`=== END`)
return nil
}
diff --git a/testdata/http_server/execute/local_test.data b/testdata/http_server/execute/local_test.data
index 5462667..4758a3c 100644
--- a/testdata/http_server/execute/local_test.data
+++ b/testdata/http_server/execute/local_test.data
@@ -40,7 +40,7 @@ data: test
id: 2
event: message
-data: - === END
+data: - === END: local /local.aww 1-
id: 3
event: end
diff --git a/testdata/local/local_encrypted.data b/testdata/local/local_encrypted.data
index a4f05ad..6e5a2df 100644
--- a/testdata/local/local_encrypted.data
+++ b/testdata/local/local_encrypted.data
@@ -2,7 +2,7 @@
- === BEGIN: local testdata/local/local_encrypted.aww 3
- --> 3: echo this_is_a_secret
this_is_a_secret
-- === END
+- === END: local testdata/local/local_encrypted.aww 3
<<< echo_encrypted_no_pass
Local: NewScript: ParseScript: template: local_encrypted.aww:3:7: executing "local_encrypted.aww" at <.Val>: error calling Val: "secret::pass" is empty
@@ -20,4 +20,4 @@ Local: NewSession: .awwan.env.vault: LoadPrivateKeyInteractive: x509: decryption
- === BEGIN: local testdata/local/sub/local_encrypted.aww 1
- --> 1: echo this_is_a_secret_in_sub
this_is_a_secret_in_sub
-- === END
+- === END: local testdata/local/sub/local_encrypted.aww 1
diff --git a/testdata/local/local_test.data b/testdata/local/local_test.data
index be86cd1..3fe3322 100644
--- a/testdata/local/local_test.data
+++ b/testdata/local/local_test.data
@@ -7,4 +7,4 @@ hello
- --> 4: #local: echo "nothing"
- --> 6: echo "local"
local
-- === END
+- === END: local testdata/local/local.aww 1-
diff --git a/testdata/play/awwanssh.test/play_test.data b/testdata/play/awwanssh.test/play_test.data
index 862d77a..e6e1323 100644
--- a/testdata/play/awwanssh.test/play_test.data
+++ b/testdata/play/awwanssh.test/play_test.data
@@ -8,4 +8,4 @@ Test on "play" command.
/home/awwanssh
- --> 5: #local: pwd
/home/awwan/src
-- === END
+- === END: play testdata/play/awwanssh.test/play.aww 1-