- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是新手,如果这听起来很天真,请原谅我。我用 fastcgi++ 写了一个脚本。我测试了基本用例。但作为一名优秀的软件工程师,我想在每次进行更改时测试脚本,以确保我不会破坏任何东西。
这是我以前做的:
这是我的目录结构:
script:
- bin
- build (contained the bash script to compile the script)
- src
- tests
- build (contained bash script to compile the test)
- src (contained the test file)
- output
我破解了我测试的方式。我曾经使用 curl 来调用我的脚本并将其输出重定向到测试/输出中的一个文件(使用相对路径)并将其与预期输出进行比较。我可以这样做,因为测试是手动编译的,我只是在将目录更改为 tests/build
后才执行测试。我最近决定使用构建系统。我选择了介子。使用介子进行测试的方法是运行 meson test
或 ninja test
。现在的问题是我无法控制测试的运行位置。
在这种情况下如何测试?你如何测试你的 fcgi 脚本?
编辑:这是我如何编译和测试的示例。这是一个完整的可验证示例:
#include <fastcgi++/request.hpp>
#include <fastcgi++/manager.hpp>
class test : public Fastcgipp::Request<char>
{
bool response() {
nlohmann::json output;
out << "Content-Type: application/json; charset:utf-8\r\n\r\n";
out << "{\"success\": true}";
}
}
int main() {
Fastcgipp::Manager<test> manager;
manager.setupSignals();
manager.listen();
manager.start();
manager.join();
}
你可以认为响应是主要的。这是您开始处理事物的地方。您可以获取输入和输出以及所有好的东西。
这就是我正在测试的方式:
TEST(test, test1) {
std::string fileName = "test.txt";
nlohmann::json input, output;
input["success"] = true;
std::system(std::string("curl -X GET \"localhost/cgi-bin/test.fcg\" > " + fileName).c_str());
std::ifstream file(fileName);
std::string out;
std::getline(file, out);
output = nlohmann::json::parse(out);
ASSERT_EQ(input, output);
std::system(std::string("rm " + fileName).c_str());
}
注意:nlohmann::json是一个json解析器,我在测试中使用的是google test
最佳答案
The problem is now I do not control from where the test is run.
默认情况下,测试在构建目录中运行,但有参数 workdir(请参阅 reference),您可以使用它来设置 将用作工作目录的绝对路径测试目录,例如:
exe = executable(...)
wdir = join_paths(meson.current_source_dir(), 'some_dir')
test('basic', exe, workdir : wdir)
检查 meson object其他可能的引用目录。
关于testing - fcgi 脚本是如何测试的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58129656/
app = redmine-2.0.1 ruby = ruby 1.9.3p194(2012-04-20 修订版 35410)[x86_64-linux] [root@by1016690 publ
我是新手,如果这听起来很天真,请原谅我。我用 fastcgi++ 写了一个脚本。我测试了基本用例。但作为一名优秀的软件工程师,我想在每次进行更改时测试脚本,以确保我不会破坏任何东西。 这是我以前做的:
我在使用 nginx 使 FCGI 应用程序在 C 中工作时遇到问题。我正在使用 spawn-fcgi 创建套接字并运行我的应用程序(我将其命名为 paste) 我想这一定是我的应用程序有问题,但我很
我正在尝试在共享托管服务提供商上设置 django。我按照 http://helpdesk.bluehost.com/index.php/kb/article/000531 上的说明进行操作 几乎让它
我正在 lighttpd +FCGI 上运行 django 安装。除了管理员之外,一切正常。 我发布某些内容(即我修改或创建模型的实例)后的重定向似乎出错了。 管理员不断将我重定向到 www.xyz.
我有一个用 C 语言编写的 FCGI 应用程序。我们遇到过客户端关闭事件连接的情况,即在页面加载期间离开页面——如果可能的话,我们希望在应用程序中检测到这一点。我们将 Web 服务器 (nginx)
我正在使用 C。例如,我如何发送 404 响应? 最佳答案 包括 Status: 404 Not Found 在您为响应生成的 header 中。 关于c - 如何在 fcgi 程序中设置状态代码?,
我目前正在尝试实现一个在 Linux 上运行的小型 FastCGI 多线程应用程序。我使用来自 fastcgi.com 的库.现在我不确定我是否真的理解 web 服务器和我的应用程序之间的 FCGI
我最近安装了一台新的 ubuntu 机器,带有 wordpress、spawn-fcgi 和 nginx。 每天早上,我都会尝试查看我的博客,但我收到 502 错误网关错误。 我试图找到一些关于为什么
我对 Lighttpd、PHP 和 CGI 有疑问。 我使用的是 OpenSUSE.10。 我已经构建了 lighttpd(版本 1.4.23)和 php(版本 5.3.0)。 这是 lightt
我正在按照说明安装 get 以克隆存储库,然后突然间我开始收到“bin/magento 必须作为 CLI 应用程序运行”错误。 当我执行 php -v 时,它显示: ea-php-cli Copyri
我正在按照 this steps 部署一个 Django 项目 我的 .htaccess 是: AddHandler fcgid-script .fcgi RewriteEngine On Rewri
我对 nginx 和 Perl FCGI 模块有一点问题。我的 FCGI 程序中有一个很长的操作,它可能比我用来通信 FCGI 的 Unix 套接字另一端的服务器(或服务器上的用户)生命周期更长。如果
我使用 fastcgi.com 的 API 用 C 编写了一个 FCGI 程序。我已经像文档所说的那样调用了 FCGI_Accept。当我运行生成的可执行文件时,它就像 CGI 程序一样运行,然后退出
如果这是一个明显的问题,我很抱歉,但我真的束手无策试图解决这个问题。 我有一个 Django 应用程序,它作为 fcgi 进程运行,并使用 Lighttpd 作为前端服务器。 我首先尝试按照文档中的建
我正在使用 django 为客户构建一个网站。它托管在共享主机上,无法使用 mod_wsgi。去年,我使用 fcgi 让它工作,但是当我回来时,它坏了。 我用一个简单的 hello world 脚本替
我想用 C++11 使用 fcgi 和 nginx 编写一个网站。目前只有结合 libc++ 的 Clang++ 完全支持 C++11。 但是当我运行我的 fcgi 程序时,当有人通过浏览器请求页面时
我遇到了一个问题,我不知道如何调试一个用 C++ 编写的基于 fastcgi 的 FCGI 程序。 . 程序由Lighttpd管理spawn-fcgi并由 nginx fastcgi 模块调用。 我写
我正在尝试通过 lighttpd + fcgi 部署我的 django 应用程序,但是当我运行 fcgi 脚本时,它给我一个错误 这是 fcgi 脚本本身: #!/usr/bin/python2.6
我正在尝试使用 mod_fascgi 和 perftools 分析在 apache 中运行的 fcgi 应用程序 (C++) >。所以是 Centos 6 x86_64。 问题如下。根据gperfto
我是一名优秀的程序员,十分优秀!