shellprocess: repair broken tests

Applying calamaresstyle to this file re-formats the
raw-string-literals, which breaks the tests. Restore
the previous string formatting.
This commit is contained in:
Adriaan de Groot 2023-10-14 00:27:44 +02:00
parent 9bd600cab6
commit d8415cfd53

View File

@ -59,22 +59,22 @@ void
ShellProcessTests::testProcessListFromList() ShellProcessTests::testProcessListFromList()
{ {
::YAML::Node doc = ::YAML::Load( R"(--- ::YAML::Node doc = ::YAML::Load( R"(---
script: script:
- "ls /tmp" - "ls /tmp"
- "ls /nonexistent" - "ls /nonexistent"
- "/bin/false" - "/bin/false"
)" ); )" );
CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( !cl.isEmpty() ); QVERIFY( !cl.isEmpty() );
QCOMPARE( cl.count(), 3 ); QCOMPARE( cl.count(), 3 );
// Contains 1 bad element // Contains 1 bad element
doc = ::YAML::Load( R"(--- doc = ::YAML::Load( R"(---
script: script:
- "ls /tmp" - "ls /tmp"
- false - false
- "ls /nonexistent" - "ls /nonexistent"
)" ); )" );
CommandList cl1( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl1( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( !cl1.isEmpty() ); QVERIFY( !cl1.isEmpty() );
QCOMPARE( cl1.count(), 2 ); // One element ignored QCOMPARE( cl1.count(), 2 ); // One element ignored
@ -84,8 +84,8 @@ void
ShellProcessTests::testProcessListFromString() ShellProcessTests::testProcessListFromString()
{ {
YAML::Node doc = YAML::Load( R"(--- YAML::Node doc = YAML::Load( R"(---
script: "ls /tmp" script: "ls /tmp"
)" ); )" );
CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( !cl.isEmpty() ); QVERIFY( !cl.isEmpty() );
@ -95,8 +95,8 @@ ShellProcessTests::testProcessListFromString()
// Not a string // Not a string
doc = YAML::Load( R"(--- doc = YAML::Load( R"(---
script: false script: false
)" ); )" );
CommandList cl1( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl1( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( cl1.isEmpty() ); QVERIFY( cl1.isEmpty() );
QCOMPARE( cl1.count(), 0 ); QCOMPARE( cl1.count(), 0 );
@ -106,10 +106,10 @@ void
ShellProcessTests::testProcessFromObject() ShellProcessTests::testProcessFromObject()
{ {
YAML::Node doc = YAML::Load( R"(--- YAML::Node doc = YAML::Load( R"(---
script: script:
command: "ls /tmp" command: "ls /tmp"
timeout: 20 timeout: 20
)" ); )" );
CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( !cl.isEmpty() ); QVERIFY( !cl.isEmpty() );
@ -122,11 +122,11 @@ void
ShellProcessTests::testProcessListFromObject() ShellProcessTests::testProcessListFromObject()
{ {
YAML::Node doc = YAML::Load( R"(--- YAML::Node doc = YAML::Load( R"(---
script: script:
- command: "ls /tmp" - command: "ls /tmp"
timeout: 12 timeout: 12
- "-/bin/false" - "-/bin/false"
)" ); )" );
CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) ); CommandList cl( Calamares::YAML::mapToVariant( doc ).value( "script" ) );
QVERIFY( !cl.isEmpty() ); QVERIFY( !cl.isEmpty() );
QCOMPARE( cl.count(), 2 ); QCOMPARE( cl.count(), 2 );
@ -139,21 +139,21 @@ void
ShellProcessTests::testRootSubstitution() ShellProcessTests::testRootSubstitution()
{ {
YAML::Node doc = YAML::Load( R"(--- YAML::Node doc = YAML::Load( R"(---
script: script:
- "ls /tmp" - "ls /tmp"
)" ); )" );
QVariant plainScript = Calamares::YAML::mapToVariant( doc ).value( "script" ); QVariant plainScript = Calamares::YAML::mapToVariant( doc ).value( "script" );
QVariant rootScript = Calamares::YAML::mapToVariant( YAML::Load( R"(--- QVariant rootScript = Calamares::YAML::mapToVariant( YAML::Load( R"(---
script: script:
- "ls ${ROOT}" - "ls ${ROOT}"
)" ) ) )" ) )
.value( "script" ); .value( "script" );
QVariant userScript = Calamares::YAML::mapToVariant( YAML::Load( R"(--- QVariant userScript = Calamares::YAML::mapToVariant( YAML::Load( R"(---
script: script:
- mktemp -d ${ROOT}/calatestXXXXXXXX - mktemp -d ${ROOT}/calatestXXXXXXXX
- "chown ${USER} ${ROOT}/calatest*" - "chown ${USER} ${ROOT}/calatest*"
- rm -rf ${ROOT}/calatest* - rm -rf ${ROOT}/calatest*
)" ) ) )" ) )
.value( "script" ); .value( "script" );
if ( !Calamares::JobQueue::instance() ) if ( !Calamares::JobQueue::instance() )