All them tests

This commit is contained in:
Benjamin Bädorf 2020-11-25 14:53:12 +01:00
parent 1f207fd7c8
commit 1c3eb39403
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
50 changed files with 1183 additions and 63 deletions

0
README.md Executable file → Normal file
View file

0
package-lock.json generated Executable file → Normal file
View file

0
package.json Executable file → Normal file
View file

0
scripts/run-tests Executable file → Normal file
View file

0
src/Lexer.mjs Executable file → Normal file
View file

0
src/Parser.mjs Executable file → Normal file
View file

0
src/ast-to-data.mjs Executable file → Normal file
View file

17
src/ast-to-string.mjs Executable file → Normal file
View file

@ -1,16 +1,19 @@
function nodeToString(node) {
switch (node.type) {
case "unitFile":
return `${(node.comments || []).map(nodeToString).join('\n')}
${(node.sections || []).map(nodeToString).join('\n')}`;
return [
(node.comments || []).map(nodeToString).join('\n'),
(node.sections || []).map(nodeToString).join('\n\n'),
]
.filter(n => n !== '')
.join('\n');
case "comment":
return `# ${comment.value}`;
return `# ${node.value}`;
case "section":
const titleComment = ` ${node.titleComment ? nodeToString(node.titleComment) : ''}`;
return `[${node.title}]${titleComment}
${(node.body || []).map(nodeToString).join('\n')}`;
const titleComment = node.titleComment ? ' ' + nodeToString(node.titleComment) : '';
return `[${node.title}]${titleComment}\n${(node.body || []).map(nodeToString).join('\n')}`;
case "setting":
const comment = ` ${node.comment ? nodeToString(node.comment) : ''}`;
const comment = node.comment ? ' ' + nodeToString(node.comment) : '';
return `${node.name}=${node.value}${comment}`;
default:
throw new Error(`Unrecognized node type: ${node.type}`);

0
src/data-to-ast.mjs Executable file → Normal file
View file

0
src/data-to-string.mjs Executable file → Normal file
View file

0
src/mod.mjs Executable file → Normal file
View file

32
src/spec/ast-to-data.mjs Executable file → Normal file
View file

@ -7,7 +7,7 @@ function runTest(input, expectedOutput) {
const resultString = JSON.stringify(result);
if (expectedOutputString !== resultString) {
console.dir(input, { depth: Infinity });
throw new Error(`Mismatching result on testcase:
throw new Error(`Mismatching result on ast-to-data testcase:
=======Result======
${resultString}
@ -21,22 +21,22 @@ ${expectedOutputString}\n\n`);
(async () => {
const cases = await Promise.all([
"./parser/basic.mjs",
"./parser/comments.mjs",
"./parser/comment-only.mjs",
"./parser/multiline-value.mjs",
"./parser/weird-characters.mjs",
"./parser/repeated-settings.mjs",
"./parser/real.nix-daemon.mjs",
"./parser/real.maia-console@.mjs",
"./from-primitive/basic.mjs",
"./from-primitive/comments.mjs",
"./from-primitive/comment-only.mjs",
"./from-primitive/multiline-value.mjs",
"./from-primitive/weird-characters.mjs",
"./from-primitive/repeated-settings.mjs",
"./from-primitive/real.nix-daemon.mjs",
"./from-primitive/real.maia-console@.mjs",
/*
"./parser/real.dbus-org.bluez.mjs",
"./parser/real.display-manager.mjs",
"./parser/real.systemd-fsck-silent@.mjs",
"./parser/real.systemd-fsck-silent-root.mjs",
"./parser/real.dbus-org.freedesktop.Avahi.mjs",
"./parser/real.dbus-org.freedesktop.ModemManager1.mjs",
"./parser/real.dbus-org.freedesktop.nm-dispatcher.mjs",
"./from-primitive/real.dbus-org.bluez.mjs",
"./from-primitive/real.display-manager.mjs",
"./from-primitive/real.systemd-fsck-silent@.mjs",
"./from-primitive/real.systemd-fsck-silent-root.mjs",
"./from-primitive/real.dbus-org.freedesktop.Avahi.mjs",
"./from-primitive/real.dbus-org.freedesktop.ModemManager1.mjs",
"./from-primitive/real.dbus-org.freedesktop.nm-dispatcher.mjs",
*/
].map(file => import(file)));
const results = cases.forEach(({ ast, data }) => runTest(ast, data));

View file

@ -1,2 +0,0 @@
export const input = ;
export const result = ;

40
src/spec/ast-to-string.mjs Executable file → Normal file
View file

@ -0,0 +1,40 @@
import astToString from "../ast-to-string.mjs";
function runTest(input, expectedString) {
const resultString = astToString(input);
if (resultString !== expectedString) {
throw new Error(`mismatching result on ast-to-string testcase:
=======result======
${JSON.stringify(resultString)}
=======expected======
${JSON.stringify(expectedString)}
`);
}
};
(async () => {
const cases = await Promise.all([
"./to-primitive/basic.mjs",
"./to-primitive/comments.mjs",
"./to-primitive/comment-only.mjs",
"./to-primitive/multiline-value.mjs",
"./to-primitive/weird-characters.mjs",
"./to-primitive/repeated-settings.mjs",
"./to-primitive/real.nix-daemon.mjs",
"./to-primitive/real.maia-console@.mjs",
"./to-primitive/real.dbus-org.bluez.mjs",
"./to-primitive/real.display-manager.mjs",
"./to-primitive/real.systemd-fsck-silent@.mjs",
"./to-primitive/real.systemd-fsck-silent-root.mjs",
"./to-primitive/real.dbus-org.freedesktop.Avahi.mjs",
"./to-primitive/real.dbus-org.freedesktop.ModemManager1.mjs",
"./to-primitive/real.dbus-org.freedesktop.nm-dispatcher.mjs",
].map(file => import(file)));
const results = cases.forEach(({ ast, string }) => runTest(ast, string));
})();

39
src/spec/data-to-ast.mjs Executable file → Normal file
View file

@ -1,13 +1,14 @@
import astToData from "../data-to-ast.mjs";
import dataToAst from "../data-to-ast.mjs";
function runTest(input, expectedOutput) {
const result = astToData(input);
const result = dataToAst(input);
const expectedOutputString = JSON.stringify(expectedOutput);
const resultString = JSON.stringify(result);
if (expectedOutputString !== resultString) {
console.dir(input, { depth: Infinity });
throw new Error(`Mismatching result on testcase:
throw new Error(`Mismatching result on data-to-ast testcase:
=======Result======
${resultString}
@ -21,24 +22,24 @@ ${expectedOutputString}\n\n`);
(async () => {
const cases = await Promise.all([
"./parser/basic.mjs",
"./parser/comments.mjs",
"./parser/comment-only.mjs",
"./parser/multiline-value.mjs",
"./parser/weird-characters.mjs",
"./parser/repeated-settings.mjs",
"./parser/real.nix-daemon.mjs",
"./parser/real.maia-console@.mjs",
"./to-primitive/basic.mjs",
// "./to-primitive/comments.mjs",
// "./to-primitive/comment-only.mjs",
"./to-primitive/multiline-value.mjs",
"./to-primitive/weird-characters.mjs",
"./to-primitive/repeated-settings.mjs",
"./to-primitive/real.nix-daemon.mjs",
"./to-primitive/real.maia-console@.mjs",
/*
"./parser/real.dbus-org.bluez.mjs",
"./parser/real.display-manager.mjs",
"./parser/real.systemd-fsck-silent@.mjs",
"./parser/real.systemd-fsck-silent-root.mjs",
"./parser/real.dbus-org.freedesktop.Avahi.mjs",
"./parser/real.dbus-org.freedesktop.ModemManager1.mjs",
"./parser/real.dbus-org.freedesktop.nm-dispatcher.mjs",
"./to-primitive/real.dbus-org.bluez.mjs",
"./to-primitive/real.display-manager.mjs",
"./to-primitive/real.systemd-fsck-silent@.mjs",
"./to-primitive/real.systemd-fsck-silent-root.mjs",
"./to-primitive/real.dbus-org.freedesktop.Avahi.mjs",
"./to-primitive/real.dbus-org.freedesktop.ModemManager1.mjs",
"./to-primitive/real.dbus-org.freedesktop.nm-dispatcher.mjs",
*/
].map(file => import(file)));
const results = cases.forEach(({ ast, data }) => runTest(ast, data));
const results = cases.forEach(({ data, ast }) => runTest(data, ast));
})();

View file

View file

32
src/spec/string-to-ast.mjs Executable file → Normal file
View file

@ -6,7 +6,7 @@ function runTest(input, result) {
const resultString = JSON.stringify(ast, null, 2);
const expectedString = JSON.stringify(result, null, 2);
if (resultString !== expectedString) {
throw new Error(`mismatching result on testcase:
throw new Error(`mismatching result on string-to-ast testcase:
${input}
=======result======
@ -23,21 +23,21 @@ ${expectedString}
(async () => {
const cases = await Promise.all([
"./parser/basic.mjs",
"./parser/comments.mjs",
"./parser/comment-only.mjs",
"./parser/multiline-value.mjs",
"./parser/weird-characters.mjs",
"./parser/repeated-settings.mjs",
"./parser/real.nix-daemon.mjs",
"./parser/real.maia-console@.mjs",
"./parser/real.dbus-org.bluez.mjs",
"./parser/real.display-manager.mjs",
"./parser/real.systemd-fsck-silent@.mjs",
"./parser/real.systemd-fsck-silent-root.mjs",
"./parser/real.dbus-org.freedesktop.Avahi.mjs",
"./parser/real.dbus-org.freedesktop.ModemManager1.mjs",
"./parser/real.dbus-org.freedesktop.nm-dispatcher.mjs",
"./from-primitive/basic.mjs",
"./from-primitive/comments.mjs",
"./from-primitive/comment-only.mjs",
"./from-primitive/multiline-value.mjs",
"./from-primitive/weird-characters.mjs",
"./from-primitive/repeated-settings.mjs",
"./from-primitive/real.nix-daemon.mjs",
"./from-primitive/real.maia-console@.mjs",
"./from-primitive/real.dbus-org.bluez.mjs",
"./from-primitive/real.display-manager.mjs",
"./from-primitive/real.systemd-fsck-silent@.mjs",
"./from-primitive/real.systemd-fsck-silent-root.mjs",
"./from-primitive/real.dbus-org.freedesktop.Avahi.mjs",
"./from-primitive/real.dbus-org.freedesktop.ModemManager1.mjs",
"./from-primitive/real.dbus-org.freedesktop.nm-dispatcher.mjs",
].map(file => import(file)));
const results = cases.forEach(({ string, ast }) => runTest(string, ast));
})();

View file

@ -1,11 +1,13 @@
export const input = {
export const string = `[Unit]
Description=Idle manager for Wayland`;
export const ast = {
type: 'unitFile',
comments: [],
sections: [
{
type: 'section',
title: 'Unit',
titleComment: undefined,
body: [
{
type: 'setting',
@ -17,7 +19,7 @@ export const input = {
]
};
export const output = [
export const data = [
{
title: 'Unit',
settings: {

View file

@ -0,0 +1,9 @@
export const string = `# Start of file comment`;
export const ast = {
type: 'unitFile',
comments: [ { type: 'comment', value: 'Start of file comment' } ],
sections: [],
};
export const data = [];

View file

@ -0,0 +1,65 @@
export const string = `[Unit] # Heading comment
Description=Idle manager for Wayland # End of value comment
# Inline comment
ExecStart=echo\
"some string" # End of value comment
Alias=asdf # Comment Without spaces
[Install]
# Comment only in this body`;
export const ast = {
type: 'unitFile',
comments: [],
sections: [
{
type: 'section',
title: 'Unit',
titleComment: { type: 'comment', value: 'Heading comment' },
body: [
{
type: 'setting',
name: 'Description',
value: 'Idle manager for Wayland',
comment: { type: 'comment', value: 'End of value comment' }
},
{ type: 'comment', value: 'Inline comment' },
{
type: 'setting',
name: 'ExecStart',
value: 'echo "some string"',
comment: { type: 'comment', value: 'End of value comment' }
},
{
type: 'setting',
name: 'Alias',
value: 'asdf',
comment: { type: 'comment', value: 'Comment Without spaces' }
}
]
},
{
type: 'section',
title: 'Install',
titleComment: undefined,
body: [
{ type: 'comment', value: 'Comment only in this body' },
]
}
]
};
export const data = [
{
title: 'Unit',
settings: {
Description: 'Idle manager for Wayland',
ExecStart: 'echo "some string"',
Alias: 'asdf',
},
},
{
title: 'Install',
settings: {},
}
];

View file

@ -0,0 +1,57 @@
export const string = `[Service]
ExecStart=/usr/bin/swayidle -w \\
timeout 600 'swaylock-bg' \\
timeout 900 'swaymsg "output * dpms off"' \\
resume 'swaymsg "output * dpms on"' \\
after-resume 'swaylock-bg'
ExecStop=/usr/bin/swayidle -w \\
after-resume 'swaylock-bg'
ExecPause=/usr/bin/swayidle -w \\
after-resume 'swaylock-bg'`;
export const ast = {
type: 'unitFile',
comments: [],
sections: [
{
type: 'section',
title: 'Service',
body: [
{
type: 'setting',
name: 'ExecStart',
value: '/usr/bin/swayidle -w \\\n' +
" timeout 600 'swaylock-bg' \\\n" +
` timeout 900 'swaymsg "output * dpms off"' \\\n` +
` resume 'swaymsg "output * dpms on"' \\\n` +
" after-resume 'swaylock-bg'",
},
{
type: 'setting',
name: 'ExecStop',
value: "/usr/bin/swayidle -w \\\n after-resume 'swaylock-bg'",
},
{
type: 'setting',
name: 'ExecPause',
value: "/usr/bin/swayidle -w \\\n after-resume 'swaylock-bg'",
}
]
}
]
};
export const data = [
{
title: 'Service',
settings: {
ExecStart: '/usr/bin/swayidle -w \\\n' +
" timeout 600 'swaylock-bg' \\\n" +
` timeout 900 'swaymsg "output * dpms off"' \\\n` +
` resume 'swaymsg "output * dpms on"' \\\n` +
" after-resume 'swaylock-bg'",
ExecStop: "/usr/bin/swayidle -w \\\n after-resume 'swaylock-bg'",
ExecPause: "/usr/bin/swayidle -w \\\n after-resume 'swaylock-bg'",
},
},
];

View file

@ -0,0 +1,108 @@
export const string = `[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full
[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "Bluetooth service"
},
{
"type": "setting",
"name": "Documentation",
"value": "man:bluetoothd(8)"
},
{
"type": "setting",
"name": "ConditionPathIsDirectory",
"value": "/sys/class/bluetooth"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "dbus"
},
{
"type": "setting",
"name": "BusName",
"value": "org.bluez"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/lib/bluetooth/bluetoothd"
},
{
"type": "setting",
"name": "NotifyAccess",
"value": "main"
},
{
"type": "setting",
"name": "CapabilityBoundingSet",
"value": "CAP_NET_ADMIN CAP_NET_BIND_SERVICE"
},
{
"type": "setting",
"name": "LimitNPROC",
"value": "1"
},
{
"type": "setting",
"name": "ProtectHome",
"value": "true"
},
{
"type": "setting",
"name": "ProtectSystem",
"value": "full"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "WantedBy",
"value": "bluetooth.target"
},
{
"type": "setting",
"name": "Alias",
"value": "dbus-org.bluez.service"
}
]
}
]
};

View file

@ -0,0 +1,90 @@
export const string = `[Unit]
Description=Avahi mDNS/DNS-SD Stack
Requires=avahi-daemon.socket
[Service]
Type=dbus
BusName=org.freedesktop.Avahi
ExecStart=/usr/bin/avahi-daemon -s
ExecReload=/usr/bin/avahi-daemon -r
NotifyAccess=main
[Install]
WantedBy=multi-user.target
Also=avahi-daemon.socket
Alias=dbus-org.freedesktop.Avahi.service`
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "Avahi mDNS/DNS-SD Stack"
},
{
"type": "setting",
"name": "Requires",
"value": "avahi-daemon.socket"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "dbus"
},
{
"type": "setting",
"name": "BusName",
"value": "org.freedesktop.Avahi"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/bin/avahi-daemon -s"
},
{
"type": "setting",
"name": "ExecReload",
"value": "/usr/bin/avahi-daemon -r"
},
{
"type": "setting",
"name": "NotifyAccess",
"value": "main"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "WantedBy",
"value": "multi-user.target"
},
{
"type": "setting",
"name": "Also",
"value": "avahi-daemon.socket"
},
{
"type": "setting",
"name": "Alias",
"value": "dbus-org.freedesktop.Avahi.service"
}
]
}
]
};

View file

@ -0,0 +1,132 @@
export const string = `[Unit]
Description=Modem Manager
After=polkit.service
Requires=polkit.service
[Service]
Type=dbus
BusName=org.freedesktop.ModemManager1
ExecStart=/usr/bin/ModemManager
StandardError=null
Restart=on-abort
CapabilityBoundingSet=CAP_SYS_ADMIN
ProtectSystem=true
ProtectHome=true
PrivateTmp=true
RestrictAddressFamilies=AF_NETLINK AF_UNIX
NoNewPrivileges=true
User=root
[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.ModemManager1.service`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "Modem Manager"
},
{
"type": "setting",
"name": "After",
"value": "polkit.service"
},
{
"type": "setting",
"name": "Requires",
"value": "polkit.service"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "dbus"
},
{
"type": "setting",
"name": "BusName",
"value": "org.freedesktop.ModemManager1"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/bin/ModemManager"
},
{
"type": "setting",
"name": "StandardError",
"value": "null"
},
{
"type": "setting",
"name": "Restart",
"value": "on-abort"
},
{
"type": "setting",
"name": "CapabilityBoundingSet",
"value": "CAP_SYS_ADMIN"
},
{
"type": "setting",
"name": "ProtectSystem",
"value": "true"
},
{
"type": "setting",
"name": "ProtectHome",
"value": "true"
},
{
"type": "setting",
"name": "PrivateTmp",
"value": "true"
},
{
"type": "setting",
"name": "RestrictAddressFamilies",
"value": "AF_NETLINK AF_UNIX"
},
{
"type": "setting",
"name": "NoNewPrivileges",
"value": "true"
},
{
"type": "setting",
"name": "User",
"value": "root"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "WantedBy",
"value": "multi-user.target"
},
{
"type": "setting",
"name": "Alias",
"value": "dbus-org.freedesktop.ModemManager1.service"
}
]
}
]
};

View file

@ -0,0 +1,66 @@
export const string = `[Unit]
Description=Network Manager Script Dispatcher Service
[Service]
Type=dbus
BusName=org.freedesktop.nm_dispatcher
ExecStart=/usr/lib/nm-dispatcher
KillMode=process
[Install]
Alias=dbus-org.freedesktop.nm-dispatcher.service`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "Network Manager Script Dispatcher Service"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "dbus"
},
{
"type": "setting",
"name": "BusName",
"value": "org.freedesktop.nm_dispatcher"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/lib/nm-dispatcher"
},
{
"type": "setting",
"name": "KillMode",
"value": "process"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "Alias",
"value": "dbus-org.freedesktop.nm-dispatcher.service"
}
]
}
]
};

View file

@ -0,0 +1,90 @@
export const string = `[Unit]
Description=TUI display manager
After=systemd-user-sessions.service plymouth-quit-wait.service
After=getty@tty2.service
[Service]
Type=idle
ExecStart=/usr/bin/ly
StandardInput=tty
TTYPath=/dev/tty2
TTYReset=yes
TTYVHangup=yes
[Install]
Alias=display-manager.service`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "TUI display manager"
},
{
"type": "setting",
"name": "After",
"value": "systemd-user-sessions.service plymouth-quit-wait.service"
},
{
"type": "setting",
"name": "After",
"value": "getty@tty2.service"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "idle"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/bin/ly"
},
{
"type": "setting",
"name": "StandardInput",
"value": "tty"
},
{
"type": "setting",
"name": "TTYPath",
"value": "/dev/tty2"
},
{
"type": "setting",
"name": "TTYReset",
"value": "yes"
},
{
"type": "setting",
"name": "TTYVHangup",
"value": "yes"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "Alias",
"value": "display-manager.service"
}
]
}
]
};

View file

@ -0,0 +1,104 @@
export const string = `[Unit]
Description=maia color scheme for the console
After=getty@%i.service
[Service]
Type=oneshot
ExecStart=/usr/bin/maia-console
StandardOutput=tty
TTYPath=/dev/%i
TTYVTDisallocate=yes
[Install]
WantedBy=getty@%i.service`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "maia color scheme for the console"
},
{
"type": "setting",
"name": "After",
"value": "getty@%i.service"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "oneshot"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/bin/maia-console"
},
{
"type": "setting",
"name": "StandardOutput",
"value": "tty"
},
{
"type": "setting",
"name": "TTYPath",
"value": "/dev/%i"
},
{
"type": "setting",
"name": "TTYVTDisallocate",
"value": "yes"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "WantedBy",
"value": "getty@%i.service"
}
]
}
]
};
export const data = [
{
title: 'Unit',
settings: {
Description: 'maia color scheme for the console',
After: 'getty@%i.service',
},
},
{
title: 'Service',
settings: {
Type: 'oneshot',
ExecStart: '/usr/bin/maia-console',
StandardOutput: 'tty',
TTYPath: '/dev/%i',
TTYVTDisallocate: 'yes',
},
},
{
title: 'Install',
settings: {
WantedBy: 'getty@%i.service',
},
},
];

View file

@ -0,0 +1,99 @@
export const string = `[Unit]
Description=Nix Daemon
RequiresMountsFor=/nix/store
RequiresMountsFor=/nix/var
ConditionPathIsReadWrite=/nix/var/nix/daemon-socket
[Service]
ExecStart=@/nix/store/fwak7l5jjl0py4wldsqjbv7p7rdzql0b-nix-2.3.9/bin/nix-daemon nix-daemon --daemon
KillMode=process
[Install]
WantedBy=multi-user.target`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "Nix Daemon"
},
{
"type": "setting",
"name": "RequiresMountsFor",
"value": "/nix/store"
},
{
"type": "setting",
"name": "RequiresMountsFor",
"value": "/nix/var"
},
{
"type": "setting",
"name": "ConditionPathIsReadWrite",
"value": "/nix/var/nix/daemon-socket"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "ExecStart",
"value": "@/nix/store/fwak7l5jjl0py4wldsqjbv7p7rdzql0b-nix-2.3.9/bin/nix-daemon nix-daemon --daemon"
},
{
"type": "setting",
"name": "KillMode",
"value": "process"
}
]
},
{
"type": "section",
"title": "Install",
"body": [
{
"type": "setting",
"name": "WantedBy",
"value": "multi-user.target"
}
]
}
]
};
export const data = [
{
title: 'Unit',
settings: {
Description: 'Nix Daemon',
RequiresMountsFor: [
'/nix/store',
'/nix/var',
],
ConditionPathIsReadWrite: '/nix/var/nix/daemon-socket',
},
},
{
title: 'Service',
settings: {
ExecStart: '@/nix/store/fwak7l5jjl0py4wldsqjbv7p7rdzql0b-nix-2.3.9/bin/nix-daemon nix-daemon --daemon',
KillMode: 'process',
},
},
{
title: 'Install',
settings: {
WantedBy: 'multi-user.target',
},
},
];

View file

@ -0,0 +1,88 @@
export const string = `[Unit]
Description=File System Check on Root Device
Documentation=man:systemd-fsck-root.service(8)
DefaultDependencies=no
Before=local-fs.target shutdown.target
ConditionPathIsReadWrite=!/
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck
StandardOutput=null
StandardError=journal+console
TimeoutSec=0`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "File System Check on Root Device"
},
{
"type": "setting",
"name": "Documentation",
"value": "man:systemd-fsck-root.service(8)"
},
{
"type": "setting",
"name": "DefaultDependencies",
"value": "no"
},
{
"type": "setting",
"name": "Before",
"value": "local-fs.target shutdown.target"
},
{
"type": "setting",
"name": "ConditionPathIsReadWrite",
"value": "!/"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "oneshot"
},
{
"type": "setting",
"name": "RemainAfterExit",
"value": "yes"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/lib/systemd/systemd-fsck"
},
{
"type": "setting",
"name": "StandardOutput",
"value": "null"
},
{
"type": "setting",
"name": "StandardError",
"value": "journal+console"
},
{
"type": "setting",
"name": "TimeoutSec",
"value": "0"
}
]
}
]
};

View file

@ -0,0 +1,94 @@
export const string = `[Unit]
Description=File System Check on %f
Documentation=man:systemd-fsck@.service(8)
DefaultDependencies=no
BindsTo=%i.device
After=%i.device systemd-fsck-silent-root.service local-fs-pre.target
Before=systemd-quotacheck.service shutdown.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck
StandardOutput=null
StandardError=journal+console
TimeoutSec=0`;
export const ast = {
"type": "unitFile",
"comments": [],
"sections": [
{
"type": "section",
"title": "Unit",
"body": [
{
"type": "setting",
"name": "Description",
"value": "File System Check on %f"
},
{
"type": "setting",
"name": "Documentation",
"value": "man:systemd-fsck@.service(8)"
},
{
"type": "setting",
"name": "DefaultDependencies",
"value": "no"
},
{
"type": "setting",
"name": "BindsTo",
"value": "%i.device"
},
{
"type": "setting",
"name": "After",
"value": "%i.device systemd-fsck-silent-root.service local-fs-pre.target"
},
{
"type": "setting",
"name": "Before",
"value": "systemd-quotacheck.service shutdown.target"
}
]
},
{
"type": "section",
"title": "Service",
"body": [
{
"type": "setting",
"name": "Type",
"value": "oneshot"
},
{
"type": "setting",
"name": "RemainAfterExit",
"value": "yes"
},
{
"type": "setting",
"name": "ExecStart",
"value": "/usr/lib/systemd/systemd-fsck"
},
{
"type": "setting",
"name": "StandardOutput",
"value": "null"
},
{
"type": "setting",
"name": "StandardError",
"value": "journal+console"
},
{
"type": "setting",
"name": "TimeoutSec",
"value": "0"
}
]
}
]
};

View file

@ -0,0 +1,45 @@
export const string = `[Install]
After=something.service
After=something-else.service
After=something-different.service`;
export const ast = {
type: 'unitFile',
comments: [],
sections: [
{
type: 'section',
title: 'Install',
body: [
{
type: 'setting',
name: 'After',
value: 'something.service',
},
{
type: 'setting',
name: 'After',
value: 'something-else.service',
},
{
type: 'setting',
name: 'After',
value: 'something-different.service',
}
]
}
]
};
export const data = [
{
title: 'Install',
settings: {
After: [
'something.service',
'something-else.service',
'something-different.service',
],
},
}
];

View file

@ -0,0 +1,29 @@
export const string = `[Install]
Description=Test description(1) https://something/? \\#`;
export const ast = {
type: 'unitFile',
comments: [],
sections: [
{
type: 'section',
title: 'Install',
body: [
{
type: 'setting',
name: 'Description',
value: 'Test description(1) https://something/? \\#',
}
]
}
]
};
export const data = [
{
title: 'Install',
settings: {
Description: 'Test description(1) https://something/? \\#',
},