Git Product home page Git Product logo

Comments (5)

TeamPlatform1 avatar TeamPlatform1 commented on July 20, 2024 1

A snippet from our main.cpp:

::ApprovalTests::initializeApprovalTestsForGoogleTests();
APPROVAL_TESTS_REGISTER_MAIN_DIRECTORY
auto defaultNamer = ::ApprovalTests::Approvals::useAsDefaultNamer([]()
  {
    auto approvalFilesBaseDir = kernel::utilities::Environment::GetEnvironmentVariable(L"KERNEL_TEST_APPROVAL_FILES_BASE_DIR");
    return std::make_shared<ApprovalTests::TemplatedCustomNamer>(
      kernel::utilities::Convert::WStringToUTF8String(approvalFilesBaseDir) + 
      "/{RelativeTestSourceDirectory}/{TestFileName}.{TestCaseName}.{ApprovedOrReceived}.{FileExtension}"
    );
  });

In the environment variable I tried using something like
"//server/base/path" and
"\\server\base\path" (we're on windows).

In both cases the doubled (back)slash is eliminated in "removeRedundantDirectorySeparators". Looks like using a UNC path is currently impossible.

from approvaltests.cpp.

claremacrae avatar claremacrae commented on July 20, 2024 1

Thanks.

In case it helps in future, this is how to format code so it's readable here:

```cpp
<your code...>
```

I've made that edit in your post above.

from approvaltests.cpp.

claremacrae avatar claremacrae commented on July 20, 2024

Hi,

If the TemplatesCustomNamer is instructed to create a filename starting with "//SomeHost/SomeDir..", the double (back)slash is removed in "removeRedundantDirectorySeparators", which makes it impossible to use UNC paths.

Please give a source code sample that we can use to test the problem.

And what backslash are you referring to? I only see forward slashes.

from approvaltests.cpp.

claremacrae avatar claremacrae commented on July 20, 2024

Thank you for the code.

In both cases the doubled (back)slash is eliminated in removeRedundantDirectorySeparators(). Looks like using a UNC path is currently impossible.

Yes, I'm sure that's the problem.

I see that we have no explicit tests for that function.

The fix would be be to:

  1. add tests for the existing behaviour of removeRedundantDirectorySeparators(),
  2. and then teach it to not treat double-slashes at the start of absolute paths as redundant...

from approvaltests.cpp.

claremacrae avatar claremacrae commented on July 20, 2024
  1. add tests for the existing behaviour of removeRedundantDirectorySeparators(),

Likely something like this:

TEST_CASE("Path retains initial slashes in UNC paths")
{
    const std::string start = R"(\\a\b\c.txt)";
    Path path = Path(start);
    CHECK("//a/b/c.txt" == path.toString("/"));
    CHECK("\\\\a\\b\\c.txt" == path.toString("\\"));
}

from approvaltests.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.