Skip to content

Commit 10c95bb

Browse files
committed
feat: Read test suite from stdin
1 parent d61c72f commit 10c95bb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

test/api_test_app/main.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <cstdlib>
3434
#include <future>
35+
#include <unistd.h>
3536

3637
int main(int argc, char** argv)
3738
{
@@ -121,7 +122,36 @@ int main(int argc, char** argv)
121122
interfaces.emplace_back(std::make_unique<StatsDemo>());
122123
interfaces.emplace_back(std::make_unique<TextToSpeechDemo>());
123124

124-
if (appConfig.autoRun)
125+
if (!isatty(fileno(stdin)))
126+
{
127+
appConfig.autoRun = true;
128+
std::string line;
129+
while (std::getline(std::cin, line))
130+
{
131+
bool found = false;
132+
for (const auto& interface : interfaces)
133+
{
134+
for (const auto& method : interface->methods())
135+
{
136+
if (method == line)
137+
{
138+
interface->runOption(method);
139+
found = true;
140+
break;
141+
}
142+
}
143+
if (found)
144+
{
145+
break;
146+
}
147+
}
148+
if (!found)
149+
{
150+
std::cout << "Method not found: " << line << std::endl;
151+
}
152+
}
153+
}
154+
else if (appConfig.autoRun)
125155
{
126156
for (auto& interface : interfaces)
127157
{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Accessibility.highContrastUI
2+
Device.chipsetId
3+
TextToSpeech.speak
4+
TextToSpeech.listVoices
5+
TextToSpeech.pause

0 commit comments

Comments
 (0)