From: Bjørn Erik Pedersen Date: Tue, 27 Jan 2026 15:53:27 +0000 (+0100) Subject: testscripts: Move server tests to own folder X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=00c4228f61c839431957a6750f1fe1f0016aefec;p=brevno-suite%2Fhugo testscripts: Move server tests to own folder See #14439 --- diff --git a/main_test.go b/main_test.go index 34c86034b..79d0c554e 100644 --- a/main_test.go +++ b/main_test.go @@ -32,21 +32,24 @@ import ( "github.com/bep/helpers/envhelpers" "github.com/gohugoio/hugo/commands" + "github.com/gohugoio/hugo/htesting" "github.com/rogpeppe/go-internal/testscript" ) func TestCommands(t *testing.T) { - // These are somewhat flakey and takes some time, - // so usefule to have a way to skip them when developing. - const skipEnv = "HUGOTESTING_SKIP_COMMANDS" - if os.Getenv(skipEnv) != "" { - t.Skipf("skip because %s set in env", skipEnv) - } p := commonTestScriptsParam p.Dir = "testscripts/commands" testscript.Run(t, p) } +func TestServer(t *testing.T) { + // See issue #14439 + htesting.SkipSlowTestUnlessCI(t) + p := commonTestScriptsParam + p.Dir = "testscripts/server" + testscript.Run(t, p) +} + // Tests in development can be put in "testscripts/unfinished". // Also see the watch_testscripts.sh script. func TestUnfinished(t *testing.T) { diff --git a/testscripts/commands/hugo__watch.txt b/testscripts/commands/hugo__watch.txt deleted file mode 100644 index 34538f123..000000000 --- a/testscripts/commands/hugo__watch.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Test the hugo command. - -# See https://github.com/rogpeppe/go-internal/issues/228 -[windows] skip - -hugo -w & - -sleep 3 -grep 'P1start' public/p1/index.html - -replace content/p1.md 'P1start' 'P1end' -sleep 2 -grep 'P1end' public/p1/index.html -! grep 'livereload' public/p1/index.html - -stop - --- hugo.toml -- -baseURL = "http://example.org/" -disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] --- layouts/home.html -- -Home. --- layouts/single.html -- -Title: {{ .Title }}| {{ .Content }} --- content/p1.md -- ---- -title: "P1" ---- -P1start \ No newline at end of file diff --git a/testscripts/commands/server.txt b/testscripts/commands/server.txt deleted file mode 100644 index cd843a1de..000000000 --- a/testscripts/commands/server.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Test the hugo server command. - -# We run these tests in parallel so let Hugo decide which port to use. -hugo server --renderToMemory --gc & - -waitServer - -httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 'ServerPort: \d{4,5}' 'myenv: thedevelopment' 'livereload\.js' 'Env: development' 'IsServer: true' -httpget ${HUGOTEST_BASEURL_0}doesnotexist 'custom 404' -httpget ${HUGOTEST_BASEURL_0}livereload.js 'function' - -# By default, the server renders to memory. -! exists public/index.html - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] --- config/production/params.toml -- -myenv = "theproduction" --- config/development/params.toml -- -myenv = "thedevelopment" --- layouts/home.html -- - - -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|ServerPort: {{ site.ServerPort }}|myenv: {{ .Site.Params.myenv }}|Env: {{ hugo.Environment }}|IsServer: {{ hugo.IsServer }}| - --- layouts/404.html -- -custom 404 diff --git a/testscripts/commands/server__edit_config.txt b/testscripts/commands/server__edit_config.txt deleted file mode 100644 index 983c4d3be..000000000 --- a/testscripts/commands/server__edit_config.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Test the hugo server command when editing the config file. - -# We run these tests in parallel so let Hugo decide which port to use. -hugo server --renderToMemory & - -waitServer - -httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 - -mv edits/title.toml hugo.toml - -httpget $HUGOTEST_BASEURL_0 'Title: Hugo New Server Test' $HUGOTEST_BASEURL_0 - -mv edits/addlanguage.toml hugo.toml - -httpget $HUGOTEST_BASEURL_0 'Title: Hugo New Server Test' $HUGOTEST_BASEURL_0 -httpget ${HUGOTEST_BASEURL_0}nn/ 'Hugo Nynorsk Server Test' ${HUGOTEST_BASEURL_0}nn/ - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" --- edits/title.toml -- -title = "Hugo New Server Test" -baseURL = "https://example.org/" --- edits/addlanguage.toml -- -title = "Hugo New Server Test" -baseURL = "https://example.org/" -[languages] -[languages.en] -languageName = "English" -weight = 1 -[languages.nn] -languageName = "Nynorsk" -title = "Hugo Nynorsk Server Test" -weight = 2 - --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ .Permalink }}| - - diff --git a/testscripts/commands/server__edit_content.txt b/testscripts/commands/server__edit_content.txt deleted file mode 100644 index 49cfe8c1a..000000000 --- a/testscripts/commands/server__edit_content.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Test the hugo server command when editing content. - -# We run these tests in parallel so let Hugo decide which port to use. -# Render to disk so we can check the /public dir. -hugo server & - -waitServer - -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' $HUGOTEST_BASEURL_0 - -ls public/p2 -cp stdout lsp2_1.txt -ls public/staticfiles -stdout 'static\.txt' -cp stdout lsstaticfiles_1.txt - -replace $WORK/content/p1/index.md 'P1' 'P1 New' - -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1 New' $HUGOTEST_BASEURL_0 - -ls public/p2 -cp stdout lsp2_2.txt -cmp lsp2_1.txt lsp2_2.txt -ls public/staticfiles -cp stdout lsstaticfiles_2.txt -cmp lsstaticfiles_1.txt lsstaticfiles_2.txt - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- layouts/single.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- content/_index.md -- ---- -title: Hugo Home ---- --- content/p1/index.md -- ---- -title: P1 ---- --- content/p2/index.md -- ---- -title: P2 ---- --- static/staticfiles/static.txt -- -static - - - diff --git a/testscripts/commands/server__edit_content_with_chinese_tag.txt b/testscripts/commands/server__edit_content_with_chinese_tag.txt deleted file mode 100644 index 4020a54ac..000000000 --- a/testscripts/commands/server__edit_content_with_chinese_tag.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Issue 14240. - -hugo server & - -waitServer - -httpget ${HUGOTEST_BASEURL_0}tags/%E6%AC%A2%E8%BF%8E/ '_P1_' - -replace $WORK/content/p1.md 'P1' 'P1 New' - -httpget ${HUGOTEST_BASEURL_0}tags/%E6%AC%A2%E8%BF%8E/ '_P1 New_' - -stopServer -! stderr . - --- hugo.toml -- -baseURL = "https://example.com" -disableLiveReload = true --- layouts/all.html -- -All. {{ range .Pages }}_{{ .Title }}_{{ end }}$ --- content/p1.md -- ---- -title: "P1" -tags: ["欢迎"] ---- diff --git a/testscripts/commands/server__error_recovery_edit_config.txt b/testscripts/commands/server__error_recovery_edit_config.txt deleted file mode 100644 index 6cbdfeb9d..000000000 --- a/testscripts/commands/server__error_recovery_edit_config.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Test the hugo server command when adding an error to a config file -# and then fixing it. - -hugo server & - -waitServer - -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' - -replace $WORK/hugo.toml 'title =' 'titlefoo' -httpget ${HUGOTEST_BASEURL_0}p1/ 'failed' - -replace $WORK/hugo.toml 'titlefoo' 'title =' -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' - -stopServer - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- layouts/single.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- content/_index.md -- ---- -title: Hugo Home ---- --- content/p1/index.md -- ---- -title: P1 ---- --- content/p2/index.md -- ---- -title: P2 ---- --- static/staticfiles/static.txt -- -static - - - diff --git a/testscripts/commands/server__error_recovery_edit_content.txt b/testscripts/commands/server__error_recovery_edit_content.txt deleted file mode 100644 index c95a9ab03..000000000 --- a/testscripts/commands/server__error_recovery_edit_content.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Test the hugo server command when adding a front matter error to a content file -# and then fixing it. - -hugo server & - -waitServer - -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' - -replace $WORK/content/p1/index.md 'title:' 'titlecolon' -httpget ${HUGOTEST_BASEURL_0}p1/ 'Error' - -replace $WORK/content/p1/index.md 'titlecolon' 'title:' -httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' - -stopServer - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- layouts/single.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- content/_index.md -- ---- -title: Hugo Home ---- --- content/p1/index.md -- ---- -title: P1 ---- --- content/p2/index.md -- ---- -title: P2 ---- --- static/staticfiles/static.txt -- -static - - - diff --git a/testscripts/commands/server__multihost.txt b/testscripts/commands/server__multihost.txt deleted file mode 100644 index 9a974ee01..000000000 --- a/testscripts/commands/server__multihost.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Test the hugo server command. - -# We run these tests in parallel so let Hugo decide which port to use. -hugo server --renderToMemory & - -waitServer - -# Assert home page. -httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 -httpget $HUGOTEST_BASEURL_1 'Title: Hugo Serveur Test' $HUGOTEST_BASEURL_1 - -# Assert static mount. -httpget ${HUGOTEST_BASEURL_0}mystatic/mytext.txt 'en_mytext' -httpget ${HUGOTEST_BASEURL_1}mystatic/mytext.txt 'fr_mytext' - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] - -[[module.mounts]] -source = 'static/en' -target = 'static' -lang = 'en' -[[module.mounts]] -source = 'static/fr' -target = 'static' -lang = 'fr' - -[languages] -[languages.en] -baseURL = "https://en.example.org/" -languageName = "English" -title = "Hugo Server Test" -weight = 1 -[languages.fr] -baseURL = "https://fr.example.org/" -title = "Hugo Serveur Test" -languageName = "Français" -weight = 2 --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| --- static/en/mystatic/mytext.txt -- -en_mytext --- static/fr/mystatic/mytext.txt -- -fr_mytext - - diff --git a/testscripts/commands/server__watch_hugo_stats.txt b/testscripts/commands/server__watch_hugo_stats.txt deleted file mode 100644 index f187c8281..000000000 --- a/testscripts/commands/server__watch_hugo_stats.txt +++ /dev/null @@ -1,18 +0,0 @@ -hugo server --renderToMemory & - -waitServer -stopServer -! stderr . - -exists hugo_stats.json - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] -[module] -[[module.mounts]] -source = "hugo_stats.json" -target = "assets/watching/hugo_stats.json" --- layouts/home.html -- -Home diff --git a/testscripts/commands/server__watch_moduleconfig.txt b/testscripts/commands/server__watch_moduleconfig.txt deleted file mode 100644 index 733fefdce..000000000 --- a/testscripts/commands/server__watch_moduleconfig.txt +++ /dev/null @@ -1,19 +0,0 @@ -hugo server --renderToMemory --disableLiveReload & - -waitServer -stopServer -wait -! stderr . -stdout 'Watching for config changes in.*mytheme' - - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["section", "page", "taxonomy", "term", "RSS", "sitemap", "robotsTXT", "404"] -theme = "mytheme" --- layouts/home.html -- -foo: {{ .Site.Params.foo }} --- themes/mytheme/hugo.toml -- -[params] - foo = "bar" diff --git a/testscripts/commands/server_disablelivereload.txt b/testscripts/commands/server_disablelivereload.txt deleted file mode 100644 index 59e69a512..000000000 --- a/testscripts/commands/server_disablelivereload.txt +++ /dev/null @@ -1,20 +0,0 @@ -hugo server --disableLiveReload & - -waitServer - -! grep 'livereload' public/index.html - -stopServer -! stderr . - --- hugo.toml -- -baseURL = "http://example.org/" -disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] --- layouts/home.html -- - - - - -Home. - - \ No newline at end of file diff --git a/testscripts/commands/server_disablelivereload__config.txt b/testscripts/commands/server_disablelivereload__config.txt deleted file mode 100644 index 91e0a3534..000000000 --- a/testscripts/commands/server_disablelivereload__config.txt +++ /dev/null @@ -1,21 +0,0 @@ -hugo server & - -waitServer - -! grep 'livereload' public/index.html - -stopServer -! stderr . - --- hugo.toml -- -baseURL = "http://example.org/" -disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] -disableLiveReload = true --- layouts/home.html -- - - - - -Home. - - \ No newline at end of file diff --git a/testscripts/commands/server_render_static_to_disk.txt b/testscripts/commands/server_render_static_to_disk.txt deleted file mode 100644 index 855898e9c..000000000 --- a/testscripts/commands/server_render_static_to_disk.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Test the hugo server command. - -# We run these tests in parallel so let Hugo decide which port to use. -hugo server --renderToMemory --renderStaticToDisk & - -waitServer - -httpget ${HUGOTEST_BASEURL_0}en/ 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 -httpget ${HUGOTEST_BASEURL_0}mystatic.txt 'This is a static file in English.' - -! exists public/index.html -exists public/mystatic.txt - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] -defaultContentLanguage = "en" -defaultContentLanguageInSubdir = true -[[module.mounts]] -source = 'static/en' -target = 'static' -lang = 'en' -[[module.mounts]] -source = 'static/fr' -target = 'static' -lang = 'fr' - - -[languages] -[languages.en] -languageName = "English" -title = "Hugo Server Test" -weight = 1 -[languages.fr] -title = "Hugo Serveur Test" -languageName = "Français" -weight = 2 - --- static/en/mystatic.txt -- -This is a static file in English. --- static/en/mystatic.txt -- -This is a static file in English. --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| - - diff --git a/testscripts/commands/server_render_to_memory.txt b/testscripts/commands/server_render_to_memory.txt deleted file mode 100644 index 8eca38778..000000000 --- a/testscripts/commands/server_render_to_memory.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Test the hugo server command. - -# We run these tests in parallel so let Hugo decide which port to use. -# Deliberately using the alias 'serve' here. -hugo serve --renderToMemory & - -waitServer - -httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 - -! exists public/index.html -! exists public/mystatic.txt - -stopServer -! stderr . - --- hugo.toml -- -title = "Hugo Server Test" -baseURL = "https://example.org/" -disableKinds = ["taxonomy", "term", "sitemap"] --- static/mystatic.txt -- -This is a static file. --- layouts/home.html -- -Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| - - diff --git a/testscripts/server/hugo__watch.txt b/testscripts/server/hugo__watch.txt new file mode 100644 index 000000000..34538f123 --- /dev/null +++ b/testscripts/server/hugo__watch.txt @@ -0,0 +1,29 @@ +# Test the hugo command. + +# See https://github.com/rogpeppe/go-internal/issues/228 +[windows] skip + +hugo -w & + +sleep 3 +grep 'P1start' public/p1/index.html + +replace content/p1.md 'P1start' 'P1end' +sleep 2 +grep 'P1end' public/p1/index.html +! grep 'livereload' public/p1/index.html + +stop + +-- hugo.toml -- +baseURL = "http://example.org/" +disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] +-- layouts/home.html -- +Home. +-- layouts/single.html -- +Title: {{ .Title }}| {{ .Content }} +-- content/p1.md -- +--- +title: "P1" +--- +P1start \ No newline at end of file diff --git a/testscripts/server/server.txt b/testscripts/server/server.txt new file mode 100644 index 000000000..cd843a1de --- /dev/null +++ b/testscripts/server/server.txt @@ -0,0 +1,32 @@ +# Test the hugo server command. + +# We run these tests in parallel so let Hugo decide which port to use. +hugo server --renderToMemory --gc & + +waitServer + +httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 'ServerPort: \d{4,5}' 'myenv: thedevelopment' 'livereload\.js' 'Env: development' 'IsServer: true' +httpget ${HUGOTEST_BASEURL_0}doesnotexist 'custom 404' +httpget ${HUGOTEST_BASEURL_0}livereload.js 'function' + +# By default, the server renders to memory. +! exists public/index.html + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +-- config/production/params.toml -- +myenv = "theproduction" +-- config/development/params.toml -- +myenv = "thedevelopment" +-- layouts/home.html -- + + +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|ServerPort: {{ site.ServerPort }}|myenv: {{ .Site.Params.myenv }}|Env: {{ hugo.Environment }}|IsServer: {{ hugo.IsServer }}| + +-- layouts/404.html -- +custom 404 diff --git a/testscripts/server/server__edit_config.txt b/testscripts/server/server__edit_config.txt new file mode 100644 index 000000000..983c4d3be --- /dev/null +++ b/testscripts/server/server__edit_config.txt @@ -0,0 +1,43 @@ +# Test the hugo server command when editing the config file. + +# We run these tests in parallel so let Hugo decide which port to use. +hugo server --renderToMemory & + +waitServer + +httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 + +mv edits/title.toml hugo.toml + +httpget $HUGOTEST_BASEURL_0 'Title: Hugo New Server Test' $HUGOTEST_BASEURL_0 + +mv edits/addlanguage.toml hugo.toml + +httpget $HUGOTEST_BASEURL_0 'Title: Hugo New Server Test' $HUGOTEST_BASEURL_0 +httpget ${HUGOTEST_BASEURL_0}nn/ 'Hugo Nynorsk Server Test' ${HUGOTEST_BASEURL_0}nn/ + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +-- edits/title.toml -- +title = "Hugo New Server Test" +baseURL = "https://example.org/" +-- edits/addlanguage.toml -- +title = "Hugo New Server Test" +baseURL = "https://example.org/" +[languages] +[languages.en] +languageName = "English" +weight = 1 +[languages.nn] +languageName = "Nynorsk" +title = "Hugo Nynorsk Server Test" +weight = 2 + +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ .Permalink }}| + + diff --git a/testscripts/server/server__edit_content.txt b/testscripts/server/server__edit_content.txt new file mode 100644 index 000000000..49cfe8c1a --- /dev/null +++ b/testscripts/server/server__edit_content.txt @@ -0,0 +1,55 @@ +# Test the hugo server command when editing content. + +# We run these tests in parallel so let Hugo decide which port to use. +# Render to disk so we can check the /public dir. +hugo server & + +waitServer + +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' $HUGOTEST_BASEURL_0 + +ls public/p2 +cp stdout lsp2_1.txt +ls public/staticfiles +stdout 'static\.txt' +cp stdout lsstaticfiles_1.txt + +replace $WORK/content/p1/index.md 'P1' 'P1 New' + +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1 New' $HUGOTEST_BASEURL_0 + +ls public/p2 +cp stdout lsp2_2.txt +cmp lsp2_1.txt lsp2_2.txt +ls public/staticfiles +cp stdout lsstaticfiles_2.txt +cmp lsstaticfiles_1.txt lsstaticfiles_2.txt + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- layouts/single.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- content/_index.md -- +--- +title: Hugo Home +--- +-- content/p1/index.md -- +--- +title: P1 +--- +-- content/p2/index.md -- +--- +title: P2 +--- +-- static/staticfiles/static.txt -- +static + + + diff --git a/testscripts/server/server__edit_content_with_chinese_tag.txt b/testscripts/server/server__edit_content_with_chinese_tag.txt new file mode 100644 index 000000000..4020a54ac --- /dev/null +++ b/testscripts/server/server__edit_content_with_chinese_tag.txt @@ -0,0 +1,25 @@ +# Issue 14240. + +hugo server & + +waitServer + +httpget ${HUGOTEST_BASEURL_0}tags/%E6%AC%A2%E8%BF%8E/ '_P1_' + +replace $WORK/content/p1.md 'P1' 'P1 New' + +httpget ${HUGOTEST_BASEURL_0}tags/%E6%AC%A2%E8%BF%8E/ '_P1 New_' + +stopServer +! stderr . + +-- hugo.toml -- +baseURL = "https://example.com" +disableLiveReload = true +-- layouts/all.html -- +All. {{ range .Pages }}_{{ .Title }}_{{ end }}$ +-- content/p1.md -- +--- +title: "P1" +tags: ["欢迎"] +--- diff --git a/testscripts/server/server__error_recovery_edit_config.txt b/testscripts/server/server__error_recovery_edit_config.txt new file mode 100644 index 000000000..6cbdfeb9d --- /dev/null +++ b/testscripts/server/server__error_recovery_edit_config.txt @@ -0,0 +1,42 @@ +# Test the hugo server command when adding an error to a config file +# and then fixing it. + +hugo server & + +waitServer + +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' + +replace $WORK/hugo.toml 'title =' 'titlefoo' +httpget ${HUGOTEST_BASEURL_0}p1/ 'failed' + +replace $WORK/hugo.toml 'titlefoo' 'title =' +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' + +stopServer + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- layouts/single.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- content/_index.md -- +--- +title: Hugo Home +--- +-- content/p1/index.md -- +--- +title: P1 +--- +-- content/p2/index.md -- +--- +title: P2 +--- +-- static/staticfiles/static.txt -- +static + + + diff --git a/testscripts/server/server__error_recovery_edit_content.txt b/testscripts/server/server__error_recovery_edit_content.txt new file mode 100644 index 000000000..c95a9ab03 --- /dev/null +++ b/testscripts/server/server__error_recovery_edit_content.txt @@ -0,0 +1,42 @@ +# Test the hugo server command when adding a front matter error to a content file +# and then fixing it. + +hugo server & + +waitServer + +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' + +replace $WORK/content/p1/index.md 'title:' 'titlecolon' +httpget ${HUGOTEST_BASEURL_0}p1/ 'Error' + +replace $WORK/content/p1/index.md 'titlecolon' 'title:' +httpget ${HUGOTEST_BASEURL_0}p1/ 'Title: P1' + +stopServer + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- layouts/single.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- content/_index.md -- +--- +title: Hugo Home +--- +-- content/p1/index.md -- +--- +title: P1 +--- +-- content/p2/index.md -- +--- +title: P2 +--- +-- static/staticfiles/static.txt -- +static + + + diff --git a/testscripts/server/server__multihost.txt b/testscripts/server/server__multihost.txt new file mode 100644 index 000000000..9a974ee01 --- /dev/null +++ b/testscripts/server/server__multihost.txt @@ -0,0 +1,51 @@ +# Test the hugo server command. + +# We run these tests in parallel so let Hugo decide which port to use. +hugo server --renderToMemory & + +waitServer + +# Assert home page. +httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 +httpget $HUGOTEST_BASEURL_1 'Title: Hugo Serveur Test' $HUGOTEST_BASEURL_1 + +# Assert static mount. +httpget ${HUGOTEST_BASEURL_0}mystatic/mytext.txt 'en_mytext' +httpget ${HUGOTEST_BASEURL_1}mystatic/mytext.txt 'fr_mytext' + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] + +[[module.mounts]] +source = 'static/en' +target = 'static' +lang = 'en' +[[module.mounts]] +source = 'static/fr' +target = 'static' +lang = 'fr' + +[languages] +[languages.en] +baseURL = "https://en.example.org/" +languageName = "English" +title = "Hugo Server Test" +weight = 1 +[languages.fr] +baseURL = "https://fr.example.org/" +title = "Hugo Serveur Test" +languageName = "Français" +weight = 2 +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| +-- static/en/mystatic/mytext.txt -- +en_mytext +-- static/fr/mystatic/mytext.txt -- +fr_mytext + + diff --git a/testscripts/server/server__watch_hugo_stats.txt b/testscripts/server/server__watch_hugo_stats.txt new file mode 100644 index 000000000..f187c8281 --- /dev/null +++ b/testscripts/server/server__watch_hugo_stats.txt @@ -0,0 +1,18 @@ +hugo server --renderToMemory & + +waitServer +stopServer +! stderr . + +exists hugo_stats.json + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +[module] +[[module.mounts]] +source = "hugo_stats.json" +target = "assets/watching/hugo_stats.json" +-- layouts/home.html -- +Home diff --git a/testscripts/server/server__watch_moduleconfig.txt b/testscripts/server/server__watch_moduleconfig.txt new file mode 100644 index 000000000..733fefdce --- /dev/null +++ b/testscripts/server/server__watch_moduleconfig.txt @@ -0,0 +1,19 @@ +hugo server --renderToMemory --disableLiveReload & + +waitServer +stopServer +wait +! stderr . +stdout 'Watching for config changes in.*mytheme' + + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["section", "page", "taxonomy", "term", "RSS", "sitemap", "robotsTXT", "404"] +theme = "mytheme" +-- layouts/home.html -- +foo: {{ .Site.Params.foo }} +-- themes/mytheme/hugo.toml -- +[params] + foo = "bar" diff --git a/testscripts/server/server_disablelivereload.txt b/testscripts/server/server_disablelivereload.txt new file mode 100644 index 000000000..59e69a512 --- /dev/null +++ b/testscripts/server/server_disablelivereload.txt @@ -0,0 +1,20 @@ +hugo server --disableLiveReload & + +waitServer + +! grep 'livereload' public/index.html + +stopServer +! stderr . + +-- hugo.toml -- +baseURL = "http://example.org/" +disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] +-- layouts/home.html -- + + + + +Home. + + \ No newline at end of file diff --git a/testscripts/server/server_disablelivereload__config.txt b/testscripts/server/server_disablelivereload__config.txt new file mode 100644 index 000000000..91e0a3534 --- /dev/null +++ b/testscripts/server/server_disablelivereload__config.txt @@ -0,0 +1,21 @@ +hugo server & + +waitServer + +! grep 'livereload' public/index.html + +stopServer +! stderr . + +-- hugo.toml -- +baseURL = "http://example.org/" +disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"] +disableLiveReload = true +-- layouts/home.html -- + + + + +Home. + + \ No newline at end of file diff --git a/testscripts/server/server_render_static_to_disk.txt b/testscripts/server/server_render_static_to_disk.txt new file mode 100644 index 000000000..855898e9c --- /dev/null +++ b/testscripts/server/server_render_static_to_disk.txt @@ -0,0 +1,50 @@ +# Test the hugo server command. + +# We run these tests in parallel so let Hugo decide which port to use. +hugo server --renderToMemory --renderStaticToDisk & + +waitServer + +httpget ${HUGOTEST_BASEURL_0}en/ 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 +httpget ${HUGOTEST_BASEURL_0}mystatic.txt 'This is a static file in English.' + +! exists public/index.html +exists public/mystatic.txt + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +defaultContentLanguage = "en" +defaultContentLanguageInSubdir = true +[[module.mounts]] +source = 'static/en' +target = 'static' +lang = 'en' +[[module.mounts]] +source = 'static/fr' +target = 'static' +lang = 'fr' + + +[languages] +[languages.en] +languageName = "English" +title = "Hugo Server Test" +weight = 1 +[languages.fr] +title = "Hugo Serveur Test" +languageName = "Français" +weight = 2 + +-- static/en/mystatic.txt -- +This is a static file in English. +-- static/en/mystatic.txt -- +This is a static file in English. +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| + + diff --git a/testscripts/server/server_render_to_memory.txt b/testscripts/server/server_render_to_memory.txt new file mode 100644 index 000000000..8eca38778 --- /dev/null +++ b/testscripts/server/server_render_to_memory.txt @@ -0,0 +1,26 @@ +# Test the hugo server command. + +# We run these tests in parallel so let Hugo decide which port to use. +# Deliberately using the alias 'serve' here. +hugo serve --renderToMemory & + +waitServer + +httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0 + +! exists public/index.html +! exists public/mystatic.txt + +stopServer +! stderr . + +-- hugo.toml -- +title = "Hugo Server Test" +baseURL = "https://example.org/" +disableKinds = ["taxonomy", "term", "sitemap"] +-- static/mystatic.txt -- +This is a static file. +-- layouts/home.html -- +Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}| + +