小编Fra*_*cis的帖子

从多阶段Docker构建(.NET Core 2.0)中提取单元测试结果

我正在构建一个.NET Core 2.0 Web API,我正在创建一个Docker镜像.我对Docker很陌生,如果之前已经回答了这个问题,那么道歉.

我有以下Docker文件来创建图像.特别是,我在构建过程中运行单元测试,并将结果输出到./test/test_results.xml(在构建期间创建的临时容器中,我猜).我的问题是,如何在构建完成后访问这些测试结果?

FROM microsoft/aspnetcore-build:2.0 AS build-env

WORKDIR /app

# Copy main csproj file for DataService
COPY src/DataService.csproj ./src/
RUN dotnet restore ./src/DataService.csproj

# Copy test csproj file for DataService
COPY test/DataService.Tests.csproj ./test/
RUN dotnet restore ./test/DataService.Tests.csproj

# Copy everything else (excluding elements in dockerignore)
COPY . ./

# Run the unit tests
RUN dotnet test --results-directory ./ --logger "trx;LogFileName=test_results.xml" ./test/DataService.Tests.csproj

# Publish the app to the out directory
RUN dotnet publish ./src/DataService.csproj -c Release …
Run Code Online (Sandbox Code Playgroud)

unit-testing dockerfile asp.net-core-2.0

17
推荐指数
1
解决办法
2957
查看次数

clang 上的 static constexpr 未定义引用错误

以下代码在 Visual Studio 2019 和 gcc 10.2(以及其他 gcc 版本)上可以正常编译,-std=c++11但在 clang(版本 9、10 和 11)上编译失败。

#include <map>
#include <string>

struct repo {
    static constexpr const char *x = "sth";
};

int main() {

    // 1) This compiles
    std::map<std::string, int> m1 = { {repo::x, 3} };
    
    // 2) This compiles
    std::map<std::string, std::string> m2 = { std::make_pair(repo::x, "") };
    
    // 3) This does not compile on clang
    std::map<std::string, std::string> m3 = { {repo::x, ""} };

    return 0;
}

Run Code Online (Sandbox Code Playgroud)

clang 的错误是:

... undefined …
Run Code Online (Sandbox Code Playgroud)

c++ clang constexpr

6
推荐指数
1
解决办法
1261
查看次数

Windows 与 Linux - C++ 线程池内存使用情况

我一直在研究 Windows 和 Linux (Debian) 中一些 C++ REST API 框架的内存使用情况。我特别研究了这两个框架:cpprestsdkcpp-httplib。在这两者中,都创建了一个线程池并用于为请求提供服务。

我从cpp-httplib 中获取线程池实现并将其放在下面的最小工作示例中,以显示我在 Windows 和 Linux 上观察到的内存使用情况。

#include <cassert>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>

using namespace std;

// TaskQueue and ThreadPool taken from https://github.com/yhirose/cpp-httplib
class TaskQueue {
public:
    TaskQueue() = default;
    virtual ~TaskQueue() = default;

    virtual void enqueue(std::function<void()> fn) = 0;
    virtual void shutdown() = 0;

    virtual void on_idle() {}; …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading memory-management

5
推荐指数
1
解决办法
702
查看次数