DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryLow= controls the 'memory.low' value of children. This setting has the same semantics as MemoryLow=. For details about this control attribute see cgroup-v2.txt
DefaultMemoryMin= controls the 'memory.min' value of children. This setting has the same semantics as MemoryMin=. For details about this control attribute see cgroup-v2.txt
"
+ },
+ "InaccessibleDirectories": {
+ "reason": "moved",
+ "replacedWithKey": "InaccessiblePath",
+ "documentationLink": "https://github.com/systemd/systemd/blob/v241/NEWS#L2799"
+ },
+ "MemoryLimit": {
+ "reason": "moved",
+ "replacedWithKey": "MemoryMax",
+ "documentationLink": "https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#MemoryLimit=bytes"
+ },
+ "ReadOnlyDirectories": {
+ "reason": "moved",
+ "replacedWithKey": "ReadOnlyPaths",
+ "documentationLink": "https://github.com/systemd/systemd/blob/v241/NEWS#L2799"
+ },
+ "ReadWriteDirectories": {
+ "reason": "moved",
+ "replacedWithKey": "ReadWritePaths",
+ "documentationLink": "https://github.com/systemd/systemd/blob/v241/NEWS#L2799"
+ },
+ "StartupBlockIOWeight": {
+ "reason": "moved",
+ "replacedWithKey": "StartupIOWeight",
+ "documentationLink": "https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#BlockIOWeight=weight"
+ },
+ "StartupCPUShares": {
+ "reason": "moved",
+ "replacedWithKey": "StartupCPUWeight",
+ "documentationLink": "https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#CPUShares=weight"
+ }
+ },
+ "Unit": {
+ "BindTo": {
+ "reason": "moved",
+ "replacedWithKey": "BindsTo",
+ "documentationLink": "https://github.com/systemd/systemd/commit/7f2cddae09"
+ },
+ "PropagateReloadTo": {
+ "reason": "moved",
+ "replacedWithKey": "PropagateReloadsTo",
+ "documentationLink": "https://github.com/systemd/systemd/commit/7f2cddae09"
+ },
+ "PropagateReloadFrom": {
+ "reason": "moved",
+ "replacedWithKey": "ReloadPropagatedFrom",
+ "documentationLink": "https://github.com/systemd/systemd/commit/7f2cddae09"
+ },
+ "OnFailureIsolate": {
+ "reason": "moved",
+ "replacedWithKey": "OnFailureJobMode",
+ "documentationLink": "https://github.com/systemd/systemd/commit/d420282b28"
+ },
+ "RequiresOverridable": {
+ "reason": "unsupported",
+ "unsupported": true,
+ "documentationLink": "https://github.com/systemd/systemd/blob/v241/NEWS#L3608"
+ },
+ "RequisiteOverridable": {
+ "reason": "unsupported",
+ "unsupported": true,
+ "documentationLink": "https://github.com/systemd/systemd/blob/v241/NEWS#L3608"
+ },
+ "OnSuccessJobMode": {
+ "reason": "unsupported",
+ "unsupported": true,
+ "documentationLink": "https://github.com/systemd/systemd/blob/14c811ff4a3025a3ba8b969f7228c05d31eb3796/man/org.freedesktop.systemd1.xml#L1872"
+ },
+ "StartLimitInterval": {
+ "reason": "moved",
+ "replacedWithKey": "StartLimitIntervalSec",
+ "documentationLink": "https://github.com/systemd/systemd/pull/3148/commits/f0367da7d1a61ad698a55d17b5c28ddce0dc265a"
+ }
}
}
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/annotators/InvalidSectionHeaderNameAnnotatorTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/annotators/InvalidSectionHeaderNameAnnotatorTest.kt
index 6d4f9ad9..a8acea32 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/annotators/InvalidSectionHeaderNameAnnotatorTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/annotators/InvalidSectionHeaderNameAnnotatorTest.kt
@@ -380,4 +380,92 @@ class InvalidSectionHeaderNameAnnotatorTest : AbstractUnitFileTest() {
}
+ fun testNSpawnSectionsInNSpawnFileHasNoWarnings() {
+ /*
+ * Fixture Setup
+ */
+ //language=unit file (systemd)
+ val file = """
+ [Exec]
+
+ [Files]
+
+ [Network]
+ """.trimIndent()
+
+ /*
+ * Exercise SUT
+ */
+ setupFileInEditor("file.nspawn", file)
+ val highlights = myFixture.doHighlighting()
+
+ /*
+ * Verification
+ */
+ assertSize(0, highlights)
+ }
+
+ fun testNSpawnSectionsInServiceFileHasWarnings() {
+ /*
+ * Fixture Setup
+ */
+ //language=unit file (systemd)
+ val file = """
+ [Exec]
+
+ [Files]
+
+ [Network]
+ """.trimIndent()
+
+ /*
+ * Exercise SUT
+ */
+ setupFileInEditor("file.service", file)
+ val highlights = myFixture.doHighlighting()
+
+ /*
+ * Verification
+ */
+ assertSize(3, highlights)
+
+ val highlightTexts = highlights.map { it.description }
+
+ assertContainsElements(highlightTexts, "The section Exec is not allowed in Service files, only the following are allowed: [Unit, Install, Service]")
+ assertContainsElements(highlightTexts, "The section Files is not allowed in Service files, only the following are allowed: [Unit, Install, Service]")
+ assertContainsElements(highlightTexts, "The section Network is not allowed in Service files, only the following are allowed: [Unit, Install, Service]")
+ }
+
+ fun testServiceSectionsInNSpawnFileHasWarnings() {
+ /*
+ * Fixture Setup
+ */
+ //language=unit file (systemd)
+ val file = """
+ [Unit]
+
+ [Install]
+
+ [Service]
+ """.trimIndent()
+
+ /*
+ * Exercise SUT
+ */
+ setupFileInEditor("file.nspawn", file)
+ val highlights = myFixture.doHighlighting()
+
+ /*
+ * Verification
+ */
+ assertSize(3, highlights)
+
+ val highlightTexts = highlights.map { it.description }
+
+ assertContainsElements(highlightTexts, "The section Unit is not allowed in Nspawn files, only the following are allowed: [Exec, Files, Network]")
+ assertContainsElements(highlightTexts, "The section Install is not allowed in Nspawn files, only the following are allowed: [Exec, Files, Network]")
+ assertContainsElements(highlightTexts, "The section Service is not allowed in Nspawn files, only the following are allowed: [Exec, Files, Network]")
+ }
+
}
+
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileKeyCompletionContributorTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileKeyCompletionContributorTest.kt
index ea704a8b..0ce47e8d 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileKeyCompletionContributorTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileKeyCompletionContributorTest.kt
@@ -145,4 +145,21 @@ class UnitFileKeyCompletionContributorTest : AbstractUnitFileTest() {
// Verification
assertContainsElements(completions, "DirectoryMode", "DirectoryNotEmpty", "MakeDirectory", "PathModified")
}
+
+ fun testCompletionForNSpawnFileInFilesSectionReturnsExpectedValues() {
+ // Fixture Setup
+ val file = """
+ [Files]
+ Bi$COMPLETION_POSITION
+ Inaccessible=True
+ """.trimIndent()
+ myFixture.configureByText("file.nspawn", file)
+
+ // Exercise SUT
+ val completions = basicCompletionResultStrings
+
+ // Verification
+ assertContainsElements(completions, "Bind", "BindReadOnly", "BindUser")
+ }
+
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileSectionCompletionContributorTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileSectionCompletionContributorTest.kt
index 74ac12fd..66cc406c 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileSectionCompletionContributorTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileSectionCompletionContributorTest.kt
@@ -121,6 +121,19 @@ class UnitFileSectionCompletionContributorTest : AbstractUnitFileTest() {
assertContainsElements(completions, "Install", "Unit", "Timer")
}
+ fun testCompletionOfNewSectionHeaderReturnsExpectedValuesInNSpawn() {
+ // Fixture Setup
+ val file = """
+ [Files]
+ Whatevs=Foo
+
+ [$COMPLETION_POSITION
+ """.trimIndent()
+ myFixture.configureByText("file.nspawn", file)
+ val completions = basicCompletionResultStrings
+ assertContainsElements(completions, "Exec", "Files", "Network")
+ }
+
fun testCompletionOfNewSectionInUnknownFileTypeIsEmpty() {
// Fixture Setup
val file = """
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileValueCompletionContributorTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileValueCompletionContributorTest.kt
index 97462bd9..3af25705 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileValueCompletionContributorTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileValueCompletionContributorTest.kt
@@ -126,4 +126,20 @@ class UnitFileValueCompletionContributorTest : AbstractUnitFileTest() {
// Verification
assertContainsElements(completions, "NetworkManager.service")
}
+
+ fun testCompletionOfBooleanOptionReturnsValuesInNspawnFile() {
+ // Fixture Setup
+ val file = """
+ [Network]
+ Private=$COMPLETION_POSITION
+
+ """.trimIndent()
+ myFixture.configureByText("file.nspawn", file)
+
+ // Execute SUT
+ val completions = basicCompletionResultStrings
+
+ // Verification
+ assertContainsElements(completions, "on", "off", "true", "false", "yes", "no")
+ }
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/documentation/UnitFileDocumentationProviderTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/documentation/UnitFileDocumentationProviderTest.kt
index 8ba6ee2e..973b48db 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/documentation/UnitFileDocumentationProviderTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/documentation/UnitFileDocumentationProviderTest.kt
@@ -1,8 +1,6 @@
package net.sjrx.intellij.plugins.systemdunitfiles.documentation
import com.intellij.lang.documentation.DocumentationProviderEx
-import com.intellij.psi.PsiElement
-import com.intellij.psi.impl.FakePsiElement
import junit.framework.TestCase
import net.sjrx.intellij.plugins.systemdunitfiles.AbstractUnitFileTest
@@ -215,8 +213,43 @@ class UnitFileDocumentationProviderTest : AbstractUnitFileTest() {
val psiFile = setupFileInEditor("file.service", file)
// Exercise SUT
- val unknownSectionHeader = getAllSectionInFile(psiFile)[0]
- val doc = sut.generateDoc(unknownSectionHeader, unknownSectionHeader)
+ val sectionHeader = getAllSectionInFile(psiFile)[0]
+ val doc = sut.generateDoc(sectionHeader, sectionHeader)
+
+ // Verification
+ TestCase.assertNotNull(doc)
+ TestCase.assertTrue(doc!!.length > 1)
+ }
+
+ fun testGenerateDocForKnownSectionReturnsSomeValidTextInNSpawnFile() {
+ // Fixture Setup
+ val file = """
+ [Network]
+ Private=true
+ """.trimIndent()
+ val psiFile = setupFileInEditor("file.nspawn", file)
+
+ // Exercise SUT
+ val section = getAllSectionInFile(psiFile)[0]
+ val doc = sut.generateDoc(section, section)
+
+ // Verification
+ TestCase.assertNotNull(doc)
+ TestCase.assertTrue(doc!!.length > 1)
+ }
+
+ fun testGenerateDocKnownKeySeparatorReturnsSomeValidTextInNSpawnFile() {
+ // Fixture Setup
+ val file = """
+ [Network]
+ Private=true
+ """.trimIndent()
+ val psiFile = setupFileInEditor("file.nspawn", file)
+
+ // Exercise SUT
+
+ val documentationKey = getAllKeysInFile(psiFile)[0]
+ val doc = sut.generateDoc(documentationKey, documentationKey)
// Verification
TestCase.assertNotNull(doc)
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspectionTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspectionTest.kt
index a719207f..1fdc97d7 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspectionTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspectionTest.kt
@@ -5,6 +5,7 @@ import net.sjrx.intellij.plugins.systemdunitfiles.AbstractUnitFileTest
class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
fun testNonDeprecatedOptionDoesNotThrowError() {
+ // language="unit file (systemd)"
val file = """
[Service]
ExecStart=/bin/bash
@@ -23,6 +24,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testUnknownOptionDoesNotThrowError() {
+ // language="unit file (systemd)"
val file = """
[Service]
SomeOption=/bin/bash
@@ -41,6 +43,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testSingleExampleThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Service]
MemoryLimit=8
@@ -64,6 +67,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testAllDocumentedDeprecatedOptionsInServiceAsOfV240ThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Service]
CPUShares=52
@@ -91,6 +95,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testAllDocumentedDeprecatedOptionsInMountAsOfV240ThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Mount]
CPUShares=52
@@ -118,6 +123,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testAllDocumentedDeprecatedOptionsInSocketAsOfV240ThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Socket]
CPUShares=52
@@ -145,6 +151,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testAllDocumentedDeprecatedOptionsInSwapAsOfV240ThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Swap]
CPUShares=52
@@ -172,6 +179,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
}
fun testAllDocumentedDeprecatedOptionsInSliceAsOfV240ThrowsWarning() {
+ // language="unit file (systemd)"
val file = """
[Slice]
CPUShares=52
@@ -197,4 +205,29 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
// Verification
assertSize(9, highlights)
}
+
+ fun testSingleExampleInNSpawnFileThrowsWarning() {
+
+ // language="unit file (systemd)"
+ val file = """
+ [Files]
+ PrivateUsersChown=true
+ """.trimIndent()
+
+ // Exercise SUT
+ setupFileInEditor("file.nspawn", file)
+ enableInspection(DeprecatedOptionsInspection::class.java)
+
+ // Verification
+ val highlights = myFixture.doHighlighting()
+
+
+ // Verification
+ assertSize(1, highlights)
+ val info = highlights[0]
+ TestCase.assertEquals("'PrivateUsersChown' in section 'Files' has been renamed to 'PrivateUsersOwnership'", info!!.description)
+ val highlightElement = myFixture.file.findElementAt(info.getStartOffset())
+ TestCase.assertNotNull(highlightElement)
+ TestCase.assertEquals("PrivateUsersChown", highlightElement!!.text)
+ }
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/MissingRequiredKeyInspectionTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/MissingRequiredKeyInspectionTest.kt
index 10e6dc6b..27fd2726 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/MissingRequiredKeyInspectionTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/MissingRequiredKeyInspectionTest.kt
@@ -29,7 +29,7 @@ class MissingRequiredKeyInspectionTest : AbstractUnitFileTest() {
assertSize(2, highlights)
}
- fun testServiceHasNoWarningsARequiredOptionInUnitSectionPresent() {
+ fun testServiceHasNoWarningsEnoughRequiredOptionsInUnitSectionArePresent() {
// Fixture Setup
// language="unit file (systemd)"
@@ -37,7 +37,7 @@ class MissingRequiredKeyInspectionTest : AbstractUnitFileTest() {
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Daughter Service
- SuccessAction=foo
+ SuccessAction=reboot
[Service]
Type=oneshot
@@ -358,4 +358,29 @@ class MissingRequiredKeyInspectionTest : AbstractUnitFileTest() {
assertSize(0, highlights)
}
+
+ fun testNSpawnFileHasNoWarningsWhenEmpty() {
+
+ // Fixture Setup
+ // language="unit file (systemd)"
+ val file = """
+ # SPDX-License-Identifier: LGPL-2.1-or-later
+ [Files]
+
+
+ [Network]
+
+ [Exec]
+ """.trimIndent()
+
+ // Exercise SUT
+ setupFileInEditor("file.nspawn", file)
+ enableInspection(MissingRequiredKeyInspection::class.java)
+
+ val highlights = myFixture.doHighlighting()
+
+ // Verification
+ assertSize(0, highlights)
+ }
+
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/UnknownKeyInSectionInspectionTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/UnknownKeyInSectionInspectionTest.kt
index e8c5fcde..c0ff9d6d 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/UnknownKeyInSectionInspectionTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/UnknownKeyInSectionInspectionTest.kt
@@ -682,6 +682,44 @@ class UnknownKeyInSectionInspectionTest : AbstractUnitFileTest() {
TestCase.assertEquals("BusName", highlightElement!!.text)
}
+ fun testNSpawnFileTypeThrowsWarningWithKeyFromServiceFile() {
+ // Fixture Setup
+ val file = """
+ [Exec]
+ BusName=yes
+ """.trimIndent()
+ enableInspection(UnknownKeyInSectionInspection::class.java)
+ setupFileInEditor("some.nspawn", file)
+
+ // Exercise SUT
+ val highlights = myFixture.doHighlighting()
+
+ // Verification
+ assertSize(1, highlights)
+ val info = highlights[0]
+ TestCase.assertEquals(UnknownKeyInSectionInspection.INSPECTION_TOOL_TIP_TEXT, info!!.description)
+ TestCase.assertEquals(HighlightInfoType.WARNING, info.type)
+ val highlightElement = myFixture.file.findElementAt(info.getStartOffset())
+ TestCase.assertEquals("BusName", highlightElement!!.text)
+ }
+
+ fun testNSpawnFileTypeHasNoWarningsWithKnownKey() {
+ // Fixture Setup
+ val file = """
+ [Timer]
+ RandomizedDelaySec=50
+ """.trimIndent()
+ enableInspection(UnknownKeyInSectionInspection::class.java)
+ setupFileInEditor("some.timer", file)
+
+ // Exercise SUT
+ val highlights = myFixture.doHighlighting()
+
+ // Verification
+ assertEmpty(highlights)
+ }
+
+
fun testSomeNewKeysFromSystemdV240HasNoWarnings() {
// Fixture Setup
val file = """
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataDocumentationCompletionTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataDocumentationCompletionTest.kt
index 8de53d94..2d3b9571 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataDocumentationCompletionTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataDocumentationCompletionTest.kt
@@ -7,19 +7,26 @@ class SemanticDataDocumentationCompletionTest : AbstractUnitFileTest() {
fun testAllOptions() {
val sdr = SemanticDataRepository.instance
val doc: MutableSet = TreeSet()
- for (sectionName in sdr.sectionNamesFromDocumentation) {
- for (keyName in sdr.getDocumentedKeywordsInSection(sectionName)) {
- doc.add("$sectionName.$keyName")
+
+ for (fileClass in FileClass.entries) {
+ for (sectionName in sdr.getSectionNamesForFile(fileClass.fileClass)) {
+ for (keyName in sdr.getDocumentedKeywordsInSection(fileClass, sectionName)) {
+ doc.add("${fileClass.fileClass}.$sectionName.$keyName")
+ }
}
}
val code: MutableSet = TreeSet()
- for (sectionName in sdr.sectionNamesFromValidators) {
- for (keyName in sdr.getAllowedKeywordsInSectionFromValidators(sectionName)) {
- code.add("$sectionName.$keyName")
+
+ for (fileClass in FileClass.entries) {
+ for (sectionName in sdr.getSectionNamesForFile(fileClass.fileClass)) {
+ for (keyName in sdr.getAllowedKeywordsInSectionFromValidators(fileClass, sectionName)) {
+ code.add("${fileClass.fileClass}.$sectionName.$keyName")
+ }
}
}
- println(doc.size)
- println(code.size)
+
+ println(doc.size) //0
+ println(code.size) //1131
val codeButNotDoc: MutableSet = TreeSet(code)
val docButNotCode: MutableSet = TreeSet(doc)
codeButNotDoc.removeAll(doc)
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataRepositoryTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataRepositoryTest.kt
index 1fd05890..6fa74585 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataRepositoryTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataRepositoryTest.kt
@@ -6,28 +6,32 @@ import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.*
class SemanticDataRepositoryTest : AbstractUnitFileTest() {
fun testInteresting() {
val sdr = SemanticDataRepository.instance
- assertInstanceOf(sdr.getOptionValidator("Socket", "SendSIGKILL"), BooleanOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Unit", "Documentation"), DocumentationOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Service", "KillMode"), KillModeOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Mount", "KillMode"), KillModeOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Socket", "DirectoryMode"), ModeStringOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Unit", "XXXX"), NullOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("XXXX", "Yes"), NullOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Service", "Restart"), RestartOptionValue::class.java)
- assertInstanceOf(sdr.getOptionValidator("Service", "Type"), ServiceTypeOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE,"Socket", "SendSIGKILL"), BooleanOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE,"Unit", "Documentation"), DocumentationOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE, "Service", "KillMode"), KillModeOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE,"Mount", "KillMode"), KillModeOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE, "Socket", "DirectoryMode"), ModeStringOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE , "Unit", "XXXX"), NullOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE, "XXXX", "Yes"), NullOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE, "Service", "Restart"), RestartOptionValue::class.java)
+ assertInstanceOf(sdr.getOptionValidator(FileClass.UNIT_FILE, "Service", "Type"), ServiceTypeOptionValue::class.java)
}
fun testDeclaredUnderKeywordDiffers() {
val sdr = SemanticDataRepository.instance
- for (section in sdr.sectionNamesFromDocumentation) {
- val data = sdr.getKeyValuePairsForSectionFromDocumentation(section)
- for ((key, value) in data) {
- val declaredUnderKeyword = value.declaredUnderKeyword
- if (declaredUnderKeyword != null && declaredUnderKeyword != key) {
- println("Mismatch: $section.$key: $declaredUnderKeyword")
+
+ for (fileClass in FileClass.entries) {
+ for (section in sdr.getSectionNamesForFile(fileClass.name)) {
+ val data = sdr.getKeyValuePairsForSectionFromDocumentation(fileClass, section)
+ for ((key, value) in data) {
+ val declaredUnderKeyword = value.declaredUnderKeyword
+ if (declaredUnderKeyword != null && declaredUnderKeyword != key) {
+ println("Mismatch: $section.$key: $declaredUnderKeyword")
+ }
}
}
}
+
}
fun testAllRequiredOptionsExists () {
@@ -58,7 +62,7 @@ class SemanticDataRepositoryTest : AbstractUnitFileTest() {
for (key in keys) {
val sectionAndKey = key.split('.')
- val validKeys = sdr.getAllowedKeywordsInSectionFromValidators(sectionAndKey[0])
+ val validKeys = sdr.getAllowedKeywordsInSectionFromValidators(FileClass.UNIT_FILE, sectionAndKey[0])
assertContainsElements(validKeys, sectionAndKey[1])
}
diff --git a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/OptionValueTest.kt b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/OptionValueTest.kt
index bdb97a0c..068c1953 100644
--- a/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/OptionValueTest.kt
+++ b/src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/OptionValueTest.kt
@@ -1,6 +1,7 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues
import net.sjrx.intellij.plugins.systemdunitfiles.AbstractUnitFileTest
+import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.FileClass
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.SemanticDataRepository
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
@@ -13,30 +14,34 @@ class OptionValueTest : AbstractUnitFileTest() {
val missingValidators = hashMapOf()
var totalMissingValidators = 0
var totalFoundValidators = 0
- for (sectionName in SemanticDataRepository.instance.sectionNamesFromValidators) {
- for (key in SemanticDataRepository.instance.getAllowedKeywordsInSectionFromValidators(sectionName)) {
-
-
- val validator = SemanticDataRepository.instance.getValidatorForSectionAndKey(sectionName, key)
-
- if (!validatorMap.containsKey(validator)) {
- missingValidators[validator] = (missingValidators[validator] ?: 0) + 1
- totalMissingValidators++
- } else {
- totalFoundValidators++
+ for (fileClass in FileClass.entries) {
+ for (sectionName in SemanticDataRepository.instance.getSectionNamesForFile(fileClass.fileClass)) {
+ for (key in SemanticDataRepository.instance.getAllowedKeywordsInSectionFromValidators(fileClass, sectionName)) {
+
+ val validator = SemanticDataRepository.instance.getValidatorForSectionAndKey(fileClass, sectionName, key)
+
+ if (!validatorMap.containsKey(validator)) {
+ missingValidators[validator] = (missingValidators[validator] ?: 0) + 1
+ totalMissingValidators++
+ } else {
+ totalFoundValidators++
+ }
}
}
}
-
val missingValidatorList = missingValidators.map { "${String.format("%05d", it.value)}, ${it.key}" }
val sortedList = missingValidatorList.sortedDescending().joinToString("\n")
println("Missing:$totalMissingValidators")
println("Found:$totalFoundValidators")
- if (totalMissingValidators > 560) {
+ if (totalMissingValidators > 611) {
assertEquals("Number of missing validators is too high at ${totalMissingValidators} vs. found ${totalFoundValidators}", sortedList, "")
}
+ if (totalFoundValidators == 0) {
+ fail("There are no found validators, something is wrong")
+ }
+
}
}
diff --git a/systemd-build/systemd-build.sh b/systemd-build/systemd-build.sh
index 7fb4f896..9f310aa3 100755
--- a/systemd-build/systemd-build.sh
+++ b/systemd-build/systemd-build.sh
@@ -1,12 +1,21 @@
#!/usr/bin/env bash
-
echo "Git Pull" && \
git pull && \
echo "Run jinja2" && \
python3 ./tools/meson-render-jinja2.py ./build/config.h ./src/core/load-fragment-gperf.gperf.in load-fragment-gperf.gperf && \
echo "Copy file(s)" && \
cp load-fragment-gperf.gperf /mount/load-fragment-gperf.gperf && \
+ cp ./src/journal/journald-gperf.gperf /mount/ && \
+ cp ./src/login/logind-gperf.gperf /mount/ && \
+ cp ./src/nspawn/nspawn-gperf.gperf /mount/ && \
+ cp ./src/timesync/timesyncd-gperf.gperf /mount/ && \
+ cp ./src/udev/net/link-config-gperf.gperf /mount/ && \
+ cp ./src/resolve/resolved-gperf.gperf /mount/ && \
+ cp ./src/resolve/resolved-dnssd-gperf.gperf /mount/ && \
+ cp ./src/network/netdev/netdev-gperf.gperf /mount/ && \
+ cp ./src/network/networkd-network-gperf.gperf /mount/ && \
+ cp ./src/network/networkd-gperf.gperf /mount/ && \
cp -R ./man /mount/ && \
git log --format="%at" | sort | tail -n 1 | xargs -I{} date -d @{} +%Y-%m-%d > last_commit_date && \
git rev-parse --short=10 HEAD > last_commit_hash && \