我正在尝试使用以下命令使用PHPUnit和phpdbg为我的PHP项目生成代码测试覆盖:
phpdbg -dmemory_limit=512M -qrr ./bin/phpunit -c .phpunit.cover.xml
Run Code Online (Sandbox Code Playgroud)
这非常好用:
PHPUnit 6.2.4 by Sebastian Bergmann and contributors.
........ 8 / 8 (100%)
Time: 114 ms, Memory: 14.00MB
OK (8 tests, 13 assertions)
Generating code coverage report in HTML format ... done
Run Code Online (Sandbox Code Playgroud)
但是,当我在docker容器中使用完全相同的命令时:
docker run -it --name YM4UPltmiPMjObaVULwsIPIkPL2bGL0T -e USER=sasan -v "/home/sasan/Project/phpredmin:/phpredmin" -w "/phpredmin" --user "1000:www-data" php:7.0-apache phpdbg -dmemory_limit=512M -qrr ./bin/phpunit -c .phpunit.cover.xml
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
PHPUnit 6.2.4 by Sebastian Bergmann and contributors.
[PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义分隔符的Go html /模板.
但是,我可以解析并执行我的"index.html"文件,每当我尝试更改模板分隔符时,我面临以下错误:
runtime error: invalid memory address or nil pointer dereference goroutine
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
package main
import (
"html/template"
"net/http"
)
var sherrifTmpl = template.New("test").Delims("{[{", "}]}")
func serveHome(w http.ResponseWriter, r *http.Request) {
template.Must(sherrifTmpl.ParseFiles("index.html")).Execute(w, r)
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试以下任何一项:
package main
import (
"html/template"
"net/http"
)
func serveHome(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("index.html")).Execute(w, r)
}
Run Code Online (Sandbox Code Playgroud)
要么:
package main
import (
"html/template"
"net/http"
)
var sherrifTmpl = template.New("test").Delims("{[{", "}]}")
func serveHome(w http.ResponseWriter, r *http.Request) {
template.Must(sherrifTmpl.ParseFiles("{[{.Host}]}")).Execute(w, r)
}
Run Code Online (Sandbox Code Playgroud)
一切正常.我甚至试图捕获ParseFiles错误.但仍然没有运气:
package main
import ( …Run Code Online (Sandbox Code Playgroud)