@@ -1430,3 +1430,112 @@ All.
14301430 b = hugolib .Test (t , files )
14311431 b .AssertFileContent ("public/guest/en/index.html" , "url=https://example.org/guest/\" " )
14321432}
1433+
1434+ func TestSitesMatrixRangeMatchers (t * testing.T ) {
1435+ t .Parallel ()
1436+ files := `TestSitesMatrixRangeMatchers
1437+ -- hugo.toml --
1438+ baseURL = "https://example.org/"
1439+ defaultContentVersion = "v4.0.0"
1440+ defaultContentVersionInSubDir = true
1441+ disableKinds = ["taxonomy", "term", "rss", "sitemap"]
1442+
1443+ [languages]
1444+ [languages.en]
1445+ weight = 1
1446+
1447+ [versions]
1448+ [versions."v1.0.0"]
1449+ [versions."v2.0.0"]
1450+ [versions."v2.1.0"]
1451+ [versions."v3.0.0"]
1452+ [versions."v4.0.0"]
1453+
1454+ -- content/_index.md --
1455+ ---
1456+ title: "Home"
1457+ sites:
1458+ matrix:
1459+ versions: ["**"]
1460+ ---
1461+ -- content/p1.md --
1462+ ---
1463+ title: "P1 from v2.0.0"
1464+ sites:
1465+ matrix:
1466+ versions: [">= v2.0.0"]
1467+ ---
1468+ Content for v2.0.0 and later.
1469+ -- content/p2.md --
1470+ ---
1471+ title: "P2 between v2 and v3"
1472+ sites:
1473+ matrix:
1474+ versions: [">= v2.0.0", "<= v3.0.0"]
1475+ ---
1476+ Content between v2.0.0 and v3.0.0 (inclusive).
1477+ -- content/p3.md --
1478+ ---
1479+ title: "P3 before v3"
1480+ sites:
1481+ matrix:
1482+ versions: ["< v3.0.0"]
1483+ ---
1484+ Content before v3.0.0.
1485+ -- content/p4.md --
1486+ ---
1487+ title: "P4 after v2"
1488+ sites:
1489+ matrix:
1490+ versions: ["> v2.0.0"]
1491+ ---
1492+ Content after v2.0.0 (exclusive).
1493+ -- content/p5.md --
1494+ ---
1495+ title: "P5 range with negation"
1496+ sites:
1497+ matrix:
1498+ versions: [">= v2.0.0", "! v2.1.0", "<= v4.0.0"]
1499+ ---
1500+ Content from v2.0.0 to v4.0.0 but not v2.1.0.
1501+ -- layouts/all.html --
1502+ Title: {{ .Title }}|
1503+ `
1504+
1505+ b := hugolib .Test (t , files )
1506+
1507+ // P1: >= v2.0.0 should be in v2.0.0, v2.1.0, v3.0.0, v4.0.0
1508+ b .AssertFileContent ("public/v2.0.0/p1/index.html" , "Title: P1 from v2.0.0|" )
1509+ b .AssertFileContent ("public/v2.1.0/p1/index.html" , "Title: P1 from v2.0.0|" )
1510+ b .AssertFileContent ("public/v3.0.0/p1/index.html" , "Title: P1 from v2.0.0|" )
1511+ b .AssertFileContent ("public/v4.0.0/p1/index.html" , "Title: P1 from v2.0.0|" )
1512+ b .AssertFileExists ("public/v1.0.0/p1/index.html" , false )
1513+
1514+ // P2: >= v2.0.0 AND <= v3.0.0 should be in v2.0.0, v2.1.0, v3.0.0
1515+ b .AssertFileContent ("public/v2.0.0/p2/index.html" , "Title: P2 between v2 and v3|" )
1516+ b .AssertFileContent ("public/v2.1.0/p2/index.html" , "Title: P2 between v2 and v3|" )
1517+ b .AssertFileContent ("public/v3.0.0/p2/index.html" , "Title: P2 between v2 and v3|" )
1518+ b .AssertFileExists ("public/v1.0.0/p2/index.html" , false )
1519+ b .AssertFileExists ("public/v4.0.0/p2/index.html" , false )
1520+
1521+ // P3: < v3.0.0 should be in v1.0.0, v2.0.0, v2.1.0
1522+ b .AssertFileContent ("public/v1.0.0/p3/index.html" , "Title: P3 before v3|" )
1523+ b .AssertFileContent ("public/v2.0.0/p3/index.html" , "Title: P3 before v3|" )
1524+ b .AssertFileContent ("public/v2.1.0/p3/index.html" , "Title: P3 before v3|" )
1525+ b .AssertFileExists ("public/v3.0.0/p3/index.html" , false )
1526+ b .AssertFileExists ("public/v4.0.0/p3/index.html" , false )
1527+
1528+ // P4: > v2.0.0 should be in v2.1.0, v3.0.0, v4.0.0
1529+ b .AssertFileContent ("public/v2.1.0/p4/index.html" , "Title: P4 after v2|" )
1530+ b .AssertFileContent ("public/v3.0.0/p4/index.html" , "Title: P4 after v2|" )
1531+ b .AssertFileContent ("public/v4.0.0/p4/index.html" , "Title: P4 after v2|" )
1532+ b .AssertFileExists ("public/v1.0.0/p4/index.html" , false )
1533+ b .AssertFileExists ("public/v2.0.0/p4/index.html" , false )
1534+
1535+ // P5: >= v2.0.0 AND ! v2.1.0 AND <= v4.0.0 should be in v2.0.0, v3.0.0, v4.0.0
1536+ b .AssertFileContent ("public/v2.0.0/p5/index.html" , "Title: P5 range with negation|" )
1537+ b .AssertFileContent ("public/v3.0.0/p5/index.html" , "Title: P5 range with negation|" )
1538+ b .AssertFileContent ("public/v4.0.0/p5/index.html" , "Title: P5 range with negation|" )
1539+ b .AssertFileExists ("public/v1.0.0/p5/index.html" , false )
1540+ b .AssertFileExists ("public/v2.1.0/p5/index.html" , false ) // Excluded by negation
1541+ }
0 commit comments