mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Fix and add integration test for the Bootstrap SCSS module for both Dart Sass and Libsass
This fixes the reverse filesystem lookup (absolute filename to path relative to the composite filesystem). The old logic had some assumptions about the locality of the actual files that didn't work in more complex scenarios. This commit now also adds the popular Bootstrap SCSS Hugo module to the CI build (both for libsass and dartsass transpiler), so we can hopefully avoid similar future breakage. Fixes #12178
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/bep/logg"
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
"github.com/gohugoio/hugo/hugolib"
|
||||
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/dartsass"
|
||||
)
|
||||
@@ -525,3 +526,39 @@ T1: {{ $r.Content }}
|
||||
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:13:0: number`)
|
||||
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:14:0: number`)
|
||||
}
|
||||
|
||||
// Note: This test is more or less duplicated in both of the SCSS packages (libsass and dartsass).
|
||||
func TestBootstrap(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !dartsass.Supports() {
|
||||
t.Skip()
|
||||
}
|
||||
if !htesting.IsCI() {
|
||||
t.Skip("skip (slow) test in non-CI environment")
|
||||
}
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
[module]
|
||||
[[module.imports]]
|
||||
path="github.com/gohugoio/hugo-mod-bootstrap-scss/v5"
|
||||
-- go.mod --
|
||||
module github.com/gohugoio/tests/testHugoModules
|
||||
-- assets/scss/main.scss --
|
||||
@import "bootstrap/bootstrap";
|
||||
-- layouts/index.html --
|
||||
{{ $cssOpts := (dict "transpiler" "dartsass" ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }}
|
||||
Styles: {{ $r.RelPermalink }}
|
||||
`
|
||||
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
NeedsOsFS: true,
|
||||
}).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import (
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
"github.com/gohugoio/hugo/hugolib"
|
||||
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/scss"
|
||||
)
|
||||
@@ -290,3 +291,39 @@ T1: {{ $r.Content }}
|
||||
|
||||
b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover;font-family:Hugo's New Roman}p{color:blue;font-size:var 24px}b{color:green}`)
|
||||
}
|
||||
|
||||
// Note: This test is more or less duplicated in both of the SCSS packages (libsass and dartsass).
|
||||
func TestBootstrap(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !scss.Supports() {
|
||||
t.Skip()
|
||||
}
|
||||
if !htesting.IsCI() {
|
||||
t.Skip("skip (slow) test in non-CI environment")
|
||||
}
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
[module]
|
||||
[[module.imports]]
|
||||
path="github.com/gohugoio/hugo-mod-bootstrap-scss/v5"
|
||||
-- go.mod --
|
||||
module github.com/gohugoio/tests/testHugoModules
|
||||
-- assets/scss/main.scss --
|
||||
@import "bootstrap/bootstrap";
|
||||
-- layouts/index.html --
|
||||
{{ $cssOpts := (dict "transpiler" "libsass" ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }}
|
||||
Styles: {{ $r.RelPermalink }}
|
||||
`
|
||||
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
NeedsOsFS: true,
|
||||
}).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
|
||||
}
|
||||
|
Reference in New Issue
Block a user