Skip to content

Commit 45c2037

Browse files
author
Steve Ramage
committed
Moar support
1 parent e593b79 commit 45c2037

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

src/main/resources/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/undocumentedSectionToKeywordMap.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2+
"nspawn": {
3+
"Files": {
4+
"PrivateUsersChown":{
5+
"reason": "moved",
6+
"replacedWithKey": "PrivateUsersOwnership",
7+
"documentationLink": "https://www.freedesktop.org/software/systemd/man/latest/systemd.nspawn.html#PrivateUsersOwnership="
8+
}
9+
}
10+
},
211
"unit": {
312
"Mount": {
413
"BlockIOAccounting": {

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspectionTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import net.sjrx.intellij.plugins.systemdunitfiles.AbstractUnitFileTest
55

66
class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
77
fun testNonDeprecatedOptionDoesNotThrowError() {
8+
// language="unit file (systemd)"
89
val file = """
910
[Service]
1011
ExecStart=/bin/bash
@@ -23,6 +24,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
2324
}
2425

2526
fun testUnknownOptionDoesNotThrowError() {
27+
// language="unit file (systemd)"
2628
val file = """
2729
[Service]
2830
SomeOption=/bin/bash
@@ -41,6 +43,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
4143
}
4244

4345
fun testSingleExampleThrowsWarning() {
46+
// language="unit file (systemd)"
4447
val file = """
4548
[Service]
4649
MemoryLimit=8
@@ -64,6 +67,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
6467
}
6568

6669
fun testAllDocumentedDeprecatedOptionsInServiceAsOfV240ThrowsWarning() {
70+
// language="unit file (systemd)"
6771
val file = """
6872
[Service]
6973
CPUShares=52
@@ -91,6 +95,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
9195
}
9296

9397
fun testAllDocumentedDeprecatedOptionsInMountAsOfV240ThrowsWarning() {
98+
// language="unit file (systemd)"
9499
val file = """
95100
[Mount]
96101
CPUShares=52
@@ -118,6 +123,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
118123
}
119124

120125
fun testAllDocumentedDeprecatedOptionsInSocketAsOfV240ThrowsWarning() {
126+
// language="unit file (systemd)"
121127
val file = """
122128
[Socket]
123129
CPUShares=52
@@ -145,6 +151,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
145151
}
146152

147153
fun testAllDocumentedDeprecatedOptionsInSwapAsOfV240ThrowsWarning() {
154+
// language="unit file (systemd)"
148155
val file = """
149156
[Swap]
150157
CPUShares=52
@@ -172,6 +179,7 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
172179
}
173180

174181
fun testAllDocumentedDeprecatedOptionsInSliceAsOfV240ThrowsWarning() {
182+
// language="unit file (systemd)"
175183
val file = """
176184
[Slice]
177185
CPUShares=52
@@ -197,4 +205,29 @@ class DeprecatedOptionsInspectionTest : AbstractUnitFileTest() {
197205
// Verification
198206
assertSize(9, highlights)
199207
}
208+
209+
fun testSingleExampleInNSpawnFileThrowsWarning() {
210+
211+
// language="unit file (systemd)"
212+
val file = """
213+
[Files]
214+
PrivateUsersChown=true
215+
""".trimIndent()
216+
217+
// Exercise SUT
218+
setupFileInEditor("file.nspawn", file)
219+
enableInspection(DeprecatedOptionsInspection::class.java)
220+
221+
// Verification
222+
val highlights = myFixture.doHighlighting()
223+
224+
225+
// Verification
226+
assertSize(1, highlights)
227+
val info = highlights[0]
228+
TestCase.assertEquals("'PrivateUsersChown' in section 'Files' has been renamed to 'PrivateUsersOwnership'", info!!.description)
229+
val highlightElement = myFixture.file.findElementAt(info.getStartOffset())
230+
TestCase.assertNotNull(highlightElement)
231+
TestCase.assertEquals("PrivateUsersChown", highlightElement!!.text)
232+
}
200233
}

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/SemanticDataDocumentationCompletionTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class SemanticDataDocumentationCompletionTest : AbstractUnitFileTest() {
99
val doc: MutableSet<String> = TreeSet()
1010

1111
for (fileClass in FileClass.entries) {
12-
for (sectionName in sdr.getSectionNamesForFile(fileClass.name)) {
12+
for (sectionName in sdr.getSectionNamesForFile(fileClass.fileClass)) {
1313
for (keyName in sdr.getDocumentedKeywordsInSection(fileClass, sectionName)) {
14-
doc.add("$sectionName.$keyName")
14+
doc.add("${fileClass.fileClass}.$sectionName.$keyName")
1515
}
1616
}
1717
}
@@ -20,12 +20,13 @@ class SemanticDataDocumentationCompletionTest : AbstractUnitFileTest() {
2020
for (fileClass in FileClass.entries) {
2121
for (sectionName in sdr.getSectionNamesForFile(fileClass.fileClass)) {
2222
for (keyName in sdr.getAllowedKeywordsInSectionFromValidators(fileClass, sectionName)) {
23-
code.add("$sectionName.$keyName")
23+
code.add("${fileClass.fileClass}.$sectionName.$keyName")
2424
}
2525
}
2626
}
27-
println(doc.size)
28-
println(code.size)
27+
28+
println(doc.size) //0
29+
println(code.size) //1131
2930
val codeButNotDoc: MutableSet<String> = TreeSet(code)
3031
val docButNotCode: MutableSet<String> = TreeSet(doc)
3132
codeButNotDoc.removeAll(doc)

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/OptionValueTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class OptionValueTest : AbstractUnitFileTest() {
3535

3636
println("Missing:$totalMissingValidators")
3737
println("Found:$totalFoundValidators")
38-
if (totalMissingValidators > 560) {
38+
if (totalMissingValidators > 611) {
3939
assertEquals("Number of missing validators is too high at ${totalMissingValidators} vs. found ${totalFoundValidators}", sortedList, "")
4040
}
4141

0 commit comments

Comments
 (0)