From 708bc78770a0b0361908f6404f57264c53252a95 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Thu, 28 Jul 2016 09:30:58 +0200 Subject: Optimize the multilanguage build process Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744 --- hugolib/robotstxt_test.go | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'hugolib/robotstxt_test.go') diff --git a/hugolib/robotstxt_test.go b/hugolib/robotstxt_test.go index 8e4b13db6..62be91522 100644 --- a/hugolib/robotstxt_test.go +++ b/hugolib/robotstxt_test.go @@ -30,8 +30,7 @@ const robotTxtTemplate = `User-agent: Googlebot ` func TestRobotsTXTOutput(t *testing.T) { - viper.Reset() - defer viper.Reset() + testCommonResetState() hugofs.InitMemFs() @@ -39,29 +38,15 @@ func TestRobotsTXTOutput(t *testing.T) { viper.Set("enableRobotsTXT", true) s := &Site{ - Source: &source.InMemorySource{ByteSource: weightedSources}, - Lang: newDefaultLanguage(), + Source: &source.InMemorySource{ByteSource: weightedSources}, + Language: newDefaultLanguage(), } - s.initializeSiteInfo() - - s.prepTemplates("robots.txt", robotTxtTemplate) - - createPagesAndMeta(t, s) - - if err := s.renderHomePage(); err != nil { - t.Fatalf("Unable to RenderHomePage: %s", err) - } - - if err := s.renderSitemap(); err != nil { - t.Fatalf("Unable to RenderSitemap: %s", err) - } - - if err := s.renderRobotsTXT(); err != nil { - t.Fatalf("Unable to RenderRobotsTXT :%s", err) + if err := buildAndRenderSite(s, "robots.txt", robotTxtTemplate); err != nil { + t.Fatalf("Failed to build site: %s", err) } - robotsFile, err := hugofs.Destination().Open("robots.txt") + robotsFile, err := hugofs.Destination().Open("public/robots.txt") if err != nil { t.Fatalf("Unable to locate: robots.txt") -- cgit v1.2.3