From: "Dr. Tobias Quathamer" Date: Wed, 24 Sep 2025 22:18:30 +0200 Subject: Skip tests that access the Internet during Debian build But let the test run during autopkgtest. Examples include: - TestTransformPostCSS runs "npm install" which accesses the Internet - TestHugoModulesVariants pulls in github.com/gohugoio/hugoTestModule2 - TestEmbeddedShortcodes where {{< tweet >}} shortcode accesses the Internet Origin: vendor Forwarded: not-needed Last-Update: 2021-01-27, 2022-02-23, 2022-06-07, 2022-06-08, 2023-03-09, 2023-07-06, 2023-10-10, 2024-02-23, 2024-07-14, 2024-08-18 --- hugolib/rebuild_test.go | 4 ++++ modules/client_test.go | 3 +++ .../create/create_integration_test.go | 4 ++++ .../babel/babel_integration_test.go | 4 ++++ .../cssjs/postcss_integration_test.go | 15 +++++++++++++++ .../cssjs/tailwindcss_integration_test.go | 21 +++++++++++++++++++++ .../resource_transformers/js/js_integration_test.go | 6 ++++++ 7 files changed, 57 insertions(+) diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go index f72bfaa..055e66c 100644 --- a/hugolib/rebuild_test.go +++ b/hugolib/rebuild_test.go @@ -2,6 +2,7 @@ package hugolib import ( "fmt" + "os" "path/filepath" "strings" "testing" @@ -1528,6 +1529,9 @@ foo(); } func TestRebuildVariationsAssetsPostCSSImport(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("skip CI only") } diff --git a/modules/client_test.go b/modules/client_test.go index 188646c..876ba51 100644 --- a/modules/client_test.go +++ b/modules/client_test.go @@ -34,6 +34,9 @@ import ( ) func TestClient(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("skip test as network access is not allowed during Debian package build") + } htesting.SkipSlowTestUnlessCI(t) modName := "hugo-modules-basic-test" modPath := "github.com/gohugoio/tests/" + modName diff --git a/resources/resource_factories/create/create_integration_test.go b/resources/resource_factories/create/create_integration_test.go index 783161b..7e0aaf1 100644 --- a/resources/resource_factories/create/create_integration_test.go +++ b/resources/resource_factories/create/create_integration_test.go @@ -18,6 +18,7 @@ import ( "math/rand" "net/http" "net/http/httptest" + "os" "strings" "sync" "testing" @@ -29,6 +30,9 @@ import ( ) func TestGetRemoteHead(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } files := ` -- hugo.toml -- [security] diff --git a/resources/resource_transformers/babel/babel_integration_test.go b/resources/resource_transformers/babel/babel_integration_test.go index 41f867a..ef61583 100644 --- a/resources/resource_transformers/babel/babel_integration_test.go +++ b/resources/resource_transformers/babel/babel_integration_test.go @@ -14,6 +14,7 @@ package babel_test import ( + "os" "testing" "github.com/gohugoio/hugo/htesting" @@ -21,6 +22,9 @@ import ( ) func TestTransformBabel(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } diff --git a/resources/resource_transformers/cssjs/postcss_integration_test.go b/resources/resource_transformers/cssjs/postcss_integration_test.go index 968c159..69d7643 100644 --- a/resources/resource_transformers/cssjs/postcss_integration_test.go +++ b/resources/resource_transformers/cssjs/postcss_integration_test.go @@ -100,6 +100,9 @@ module.exports = { ` func TestTransformPostCSS(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } @@ -138,6 +141,9 @@ Styles Content: Len: 770917| // 9880 func TestTransformPostCSSError(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } @@ -158,6 +164,9 @@ func TestTransformPostCSSError(t *testing.T) { // #9895 func TestTransformPostCSSImportError(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } @@ -172,6 +181,9 @@ func TestTransformPostCSSImportError(t *testing.T) { } func TestTransformPostCSSImporSkipInlineImportsNotFound(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } @@ -188,6 +200,9 @@ func TestTransformPostCSSImporSkipInlineImportsNotFound(t *testing.T) { // Issue 9787 func TestTransformPostCSSResourceCacheWithPathInBaseURL(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } diff --git a/resources/resource_transformers/cssjs/tailwindcss_integration_test.go b/resources/resource_transformers/cssjs/tailwindcss_integration_test.go index e2ce293..a1a1e5d 100644 --- a/resources/resource_transformers/cssjs/tailwindcss_integration_test.go +++ b/resources/resource_transformers/cssjs/tailwindcss_integration_test.go @@ -14,6 +14,10 @@ package cssjs_test import ( + "os" + "os/exec" + "runtime" + "strings" "testing" qt "github.com/frankban/quicktest" @@ -22,6 +26,23 @@ import ( ) func TestTailwindV4Basic(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } + if !(runtime.GOARCH == "amd64" || runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { + t.Skipf("Skip test: prebuild of @parcel/watcher is available only for x64 (amd64), arm and arm64; see https://www.npmjs.com/search?q=%%40parcel%%2Fwatcher-linux") + } + if runtime.GOARCH == "arm" { + cmd := exec.Command("/usr/bin/go", "env", "GOARM") + out, err := cmd.Output() + if err != nil { + t.Skipf("Skip test: failed to check GOARM: %v: %v", cmd, err) + } + goarm := strings.TrimSpace(string(out)) + if goarm == "5,softfloat" { + t.Skipf("Skip test: prebuild of @parcel/watcher is available for armhf but not for armel (GOARM=%v); see https://www.npmjs.com/search?q=%%40parcel%%2Fwatcher-linux", goarm) + } + } if !htesting.IsCI() { t.Skip("Skip long running test when running locally") } diff --git a/resources/resource_transformers/js/js_integration_test.go b/resources/resource_transformers/js/js_integration_test.go index a11a6fb..192c59d 100644 --- a/resources/resource_transformers/js/js_integration_test.go +++ b/resources/resource_transformers/js/js_integration_test.go @@ -79,6 +79,9 @@ JS Content:{{ $js.Content }}:End: } func TestBuildWithModAndNpm(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") } @@ -129,6 +132,9 @@ module.exports = window.ReactDOM; } func TestBuildWithNpm(t *testing.T) { + if os.Getenv("AUTOPKGTEST_TMP") == "" { + t.Skip("Skip test as network is inaccessible during Debian package build") + } if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") }