puppetlabs / cpp-hocon

A C++ port of the Typesafe Config library.
Other
81 stars 57 forks source link

include quoted string #94

Closed luben closed 5 years ago

luben commented 7 years ago

Reporting a few issues with including the configuration files. The behavior is compared with the reference implementation (typesafe-config)

First, here is the example config files:

test-1.conf

Foo {
    foo = "foo"
}

Bar {
    include "bar"
}

bar.conf:

bar = "bar"

Using this command (scala) I get the same result for all the cases described below:

scala> println(ConfigFactory.parseResourcesAnySyntax("test-1.conf").resolve().root().render() )
{
    # test-1.conf @ file: test-1.conf: 5
    "Bar" : {
        # bar.conf @ file: bar.conf: 1
        "bar" : "bar"
    },
    # test-1.conf @ file: test-1.conf: 1
    "Foo" : {
        # test-1.conf @ file: test-1.conf: 2
        "foo" : "foo"
    }
}

From C++ side I am using:

        try {
            auto cfg = hocon::config::parse_file_any_syntax(filename)->resolve();
            std::cout << "ok - validate " << filename << std::endl;
            std::cout << cfg->root()->render() << std::endl;
        } catch (const hocon::config_exception &e) {
            std::cout << "not ok - validate " << filename << std::endl;
            std::cout << "# " << e.what() << std::endl;
             failed--;
        }                                                                                                                           

with the same file from the same directory, the result is:

ok - validate test-1.conf
{
    # file: test-1.conf
    "Bar" : {},
    # file: test-1.conf
    "Foo" : {
        # file: test-1.conf
        "foo" : "foo"
    }
}

(the content of the "Bar" section is missing).

using instead:

Bar {
    include "bar.conf"                                                                                                                                                                         
}

I get an exception: "reader() should not be called on resources".

Using include file("bar") or include file("bar.conf") works as expected

MikaelSmith commented 6 years ago

I would think include "bar" might work, but it's not clear that it does.

I'm not actively working on fixing this, but will try to review fixes. Sorry that last one languished so long.

MikaelSmith commented 5 years ago

Closed as a duplicate of #98.