33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
|
|
import std;
|
||
|
|
import Crafter.Build;
|
||
|
|
using namespace Crafter;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
// Local() is the no-op runner — empty exec template, name "local".
|
||
|
|
if (TestRunner::Local().name != "local") return 1;
|
||
|
|
|
||
|
|
// FromSpec parses each known kind and labels it consistently.
|
||
|
|
auto cmd = TestRunner::FromSpec("cmd:wine");
|
||
|
|
if (!cmd || cmd->name != "cmd:wine") return 1;
|
||
|
|
|
||
|
|
auto local = TestRunner::FromSpec("local");
|
||
|
|
if (!local || local->name != "local") return 1;
|
||
|
|
|
||
|
|
auto ssh = TestRunner::FromSpec("ssh:somehost");
|
||
|
|
if (!ssh || ssh->name != "ssh:somehost") return 1;
|
||
|
|
|
||
|
|
auto sshWithDir = TestRunner::FromSpec("ssh:somehost:/var/tmp/x");
|
||
|
|
if (!sshWithDir || sshWithDir->remoteDir != "/var/tmp/x") return 1;
|
||
|
|
|
||
|
|
auto sshWin = TestRunner::FromSpec("sshwin:winhost");
|
||
|
|
if (!sshWin || sshWin->name != "sshwin:winhost") return 1;
|
||
|
|
|
||
|
|
// Empty input returns nullopt; bogus prefix throws.
|
||
|
|
if (TestRunner::FromSpec("")) return 1;
|
||
|
|
try {
|
||
|
|
TestRunner::FromSpec("nonsense:thing");
|
||
|
|
return 1;
|
||
|
|
} catch (const std::exception&) {}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|