]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
testscripts: Move server tests to own folder
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 15:53:27 +0000 (16:53 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 17:27:47 +0000 (18:27 +0100)
See #14439

29 files changed:
main_test.go
testscripts/commands/hugo__watch.txt [deleted file]
testscripts/commands/server.txt [deleted file]
testscripts/commands/server__edit_config.txt [deleted file]
testscripts/commands/server__edit_content.txt [deleted file]
testscripts/commands/server__edit_content_with_chinese_tag.txt [deleted file]
testscripts/commands/server__error_recovery_edit_config.txt [deleted file]
testscripts/commands/server__error_recovery_edit_content.txt [deleted file]
testscripts/commands/server__multihost.txt [deleted file]
testscripts/commands/server__watch_hugo_stats.txt [deleted file]
testscripts/commands/server__watch_moduleconfig.txt [deleted file]
testscripts/commands/server_disablelivereload.txt [deleted file]
testscripts/commands/server_disablelivereload__config.txt [deleted file]
testscripts/commands/server_render_static_to_disk.txt [deleted file]
testscripts/commands/server_render_to_memory.txt [deleted file]
testscripts/server/hugo__watch.txt [new file with mode: 0644]
testscripts/server/server.txt [new file with mode: 0644]
testscripts/server/server__edit_config.txt [new file with mode: 0644]
testscripts/server/server__edit_content.txt [new file with mode: 0644]
testscripts/server/server__edit_content_with_chinese_tag.txt [new file with mode: 0644]
testscripts/server/server__error_recovery_edit_config.txt [new file with mode: 0644]
testscripts/server/server__error_recovery_edit_content.txt [new file with mode: 0644]
testscripts/server/server__multihost.txt [new file with mode: 0644]
testscripts/server/server__watch_hugo_stats.txt [new file with mode: 0644]
testscripts/server/server__watch_moduleconfig.txt [new file with mode: 0644]
testscripts/server/server_disablelivereload.txt [new file with mode: 0644]
testscripts/server/server_disablelivereload__config.txt [new file with mode: 0644]
testscripts/server/server_render_static_to_disk.txt [new file with mode: 0644]
testscripts/server/server_render_to_memory.txt [new file with mode: 0644]

index 34c86034bc092d6e3933c5f41a08312d97230fff..79d0c554edbb169ccbf4d5d4617fee8b3ff3ccce 100644 (file)
@@ -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 (file)
index 34538f1..0000000
+++ /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 (file)
index cd843a1..0000000
+++ /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 --
-<!DOCTYPE html>
-<body>
-Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|ServerPort: {{ site.ServerPort }}|myenv: {{ .Site.Params.myenv }}|Env: {{ hugo.Environment }}|IsServer: {{ hugo.IsServer }}|
-</body>
--- 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 (file)
index 983c4d3..0000000
+++ /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 (file)
index 49cfe8c..0000000
+++ /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 (file)
index 4020a54..0000000
+++ /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 (file)
index 6cbdfeb..0000000
+++ /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 (file)
index c95a9ab..0000000
+++ /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 (file)
index 9a974ee..0000000
+++ /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 (file)
index f187c82..0000000
+++ /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 --
-<body>Home</body>
diff --git a/testscripts/commands/server__watch_moduleconfig.txt b/testscripts/commands/server__watch_moduleconfig.txt
deleted file mode 100644 (file)
index 733fefd..0000000
+++ /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 (file)
index 59e69a5..0000000
+++ /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 --
-<html>
-<head>
-</head>
-<body>
-Home.
-</body>
-</html>
\ 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 (file)
index 91e0a35..0000000
+++ /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 --
-<html>
-<head>
-</head>
-<body>
-Home.
-</body>
-</html>
\ 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 (file)
index 855898e..0000000
+++ /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 (file)
index 8eca387..0000000
+++ /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 (file)
index 0000000..34538f1
--- /dev/null
@@ -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 (file)
index 0000000..cd843a1
--- /dev/null
@@ -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 --
+<!DOCTYPE html>
+<body>
+Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|ServerPort: {{ site.ServerPort }}|myenv: {{ .Site.Params.myenv }}|Env: {{ hugo.Environment }}|IsServer: {{ hugo.IsServer }}|
+</body>
+-- 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 (file)
index 0000000..983c4d3
--- /dev/null
@@ -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 (file)
index 0000000..49cfe8c
--- /dev/null
@@ -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 (file)
index 0000000..4020a54
--- /dev/null
@@ -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 (file)
index 0000000..6cbdfeb
--- /dev/null
@@ -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 (file)
index 0000000..c95a9ab
--- /dev/null
@@ -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 (file)
index 0000000..9a974ee
--- /dev/null
@@ -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 (file)
index 0000000..f187c82
--- /dev/null
@@ -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 --
+<body>Home</body>
diff --git a/testscripts/server/server__watch_moduleconfig.txt b/testscripts/server/server__watch_moduleconfig.txt
new file mode 100644 (file)
index 0000000..733fefd
--- /dev/null
@@ -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 (file)
index 0000000..59e69a5
--- /dev/null
@@ -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 --
+<html>
+<head>
+</head>
+<body>
+Home.
+</body>
+</html>
\ 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 (file)
index 0000000..91e0a35
--- /dev/null
@@ -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 --
+<html>
+<head>
+</head>
+<body>
+Home.
+</body>
+</html>
\ 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 (file)
index 0000000..855898e
--- /dev/null
@@ -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 (file)
index 0000000..8eca387
--- /dev/null
@@ -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 }}|
+
+