Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions test/api_test_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,29 @@ int main(int argc, char** argv)
interfaces.emplace_back(std::make_unique<StatsDemo>());
interfaces.emplace_back(std::make_unique<TextToSpeechDemo>());

if (!isatty(fileno(stdin)))
Comment thread
brendanobra marked this conversation as resolved.
if (appConfig.autoRun)
{
int failures = 0;
for (auto& interface : interfaces)
{
std::cout << "Auto-running interface: " << interface->name() << std::endl;

for (auto& method : interface->methods())
{
std::cout << "Auto-running method: " << method << std::endl;
interface->runOption(method);
}
failures += interface->failureCount();
}
if (failures > 0)
{
std::cout << "FAILED: " << failures << " method(s) returned errors" << std::endl;
Firebolt::IFireboltAccessor::Instance().Disconnect();
return 1;
}
std::cout << "All methods succeeded" << std::endl;
}
else if (!isatty(fileno(stdin)))
{
appConfig.autoRun = true;
std::string line;
Comment thread
swethasukumarr marked this conversation as resolved.
Expand Down Expand Up @@ -198,19 +220,6 @@ int main(int argc, char** argv)
}
}
}
else if (appConfig.autoRun)
{
for (auto& interface : interfaces)
{
std::cout << "Auto-running interface: " << interface->name() << std::endl;

for (auto& method : interface->methods())
{
std::cout << "Auto-running method: " << method << std::endl;
interface->runOption(method);
}
}
}
else
{
std::vector<std::string> interfaceNames;
Expand Down
5 changes: 4 additions & 1 deletion test/api_test_app/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,23 @@ class DemoBase
std::string name() const { return name_; }
virtual void runOption(const std::string& method) = 0;
const std::vector<std::string>& methods() const { return methods_; }
int failureCount() const { return failureCount_; }

protected:
template <typename T> bool succeed(const Firebolt::Result<T>& result) const
template <typename T> bool succeed(const Firebolt::Result<T>& result)
{
if (result)
{
return true;
}
++failureCount_;
std::cout << "Error: " << static_cast<int>(result.error()) << std::endl;
return false;
}

std::string name_;
std::vector<std::string> methods_;
int failureCount_ = 0;
};

template <typename T> T chooseEnumFromList(const Firebolt::JSON::EnumType<T>& enumType, const std::string& prompt)
Expand Down
Loading