[libcalamares] Implement object-style command line

- handle command: and timeout: entries
 - test for setting the values
This commit is contained in:
Adriaan de Groot 2018-01-29 21:08:42 +01:00
parent 72bac332be
commit c641f5dec6
3 changed files with 46 additions and 1 deletions

View file

@ -102,6 +102,8 @@ script: "ls /tmp"
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
QVERIFY( !cl.isEmpty() );
QCOMPARE( cl.count(), 1 );
QCOMPARE( cl.at(0).timeout(), 10 );
QCOMPARE( cl.at(0).command(), QStringLiteral( "ls /tmp" ) );
// Not a string
doc = YAML::Load( R"(---
@ -125,6 +127,8 @@ script:
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
QVERIFY( !cl.isEmpty() );
QCOMPARE( cl.count(), 1 );
QCOMPARE( cl.at(0).timeout(), 20 );
QCOMPARE( cl.at(0).command(), QStringLiteral( "ls /tmp" ) );
}
void ShellProcessTests::testProcessListFromObject()
@ -132,11 +136,14 @@ void ShellProcessTests::testProcessListFromObject()
YAML::Node doc = YAML::Load( R"(---
script:
- command: "ls /tmp"
timeout: 20
timeout: 12
- "-/bin/false"
)" );
CommandList cl(
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
QVERIFY( !cl.isEmpty() );
QCOMPARE( cl.count(), 2 );
QCOMPARE( cl.at(0).timeout(), 12 );
QCOMPARE( cl.at(0).command(), QStringLiteral( "ls /tmp" ) );
QCOMPARE( cl.at(1).timeout(), 10 ); // default
}