Skip to content

Fix overwrites of a key when occurring in the nested section as well#9

Merged
burner merged 3 commits intoburner:masterfrom
wilzbach:fix-ini
Jun 20, 2017
Merged

Fix overwrites of a key when occurring in the nested section as well#9
burner merged 3 commits intoburner:masterfrom
wilzbach:fix-ini

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Jun 19, 2017

When adding a new feature for Dscanner (dlang-community/D-Scanner#460), I ran into this issue. I think it's best described by the test, but I also appended the cleaned dub test logs of inifiled's current behavior:

Without this patch

229 inifiled.StaticAnalysisConfig 7fffc825a0a0
242 [inifiled.StaticAnalysisConfig] inifiled.StaticAnalysisConfig 1
242 style_check="disabled" inifiled.StaticAnalysisConfig 0
258 style_check disabled
242 [inifiled.ModuleFilters] inifiled.StaticAnalysisConfig 1
249 inifiled.ModuleFilters
250 7fffc825a0a0
 229 inifiled.ModuleFilters 7fffc825a0a0
 242 style_check = "+std.algorithm" inifiled.ModuleFilters 0
 258 style_check +std.algorithm
242 style_check = "+std.algorithm" inifiled.StaticAnalysisConfig 0
258 style_check +std.algorithm
core.exception.AssertError@source/inifiled.d(575): unittest failure
----------------
??:? _d_unittestp [0x481191]
source/inifiled.d:575 void inifiled.__unittestL572_6() [0x46190d]
??:? void inifiled.__modtest() [0x47f670]
??:? scope int core.runtime.runModuleUnitTests().__foreachbody2(scope object.ModuleInfo*) [0x493a58]
??:? scope int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0x480bb7]
??:? scope int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x4863f6]
??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x486484]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0x48638b]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0x480b93]
??:? runModuleUnitTests [0x49394e]
??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x4825be]
??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x482560]
??:? _d_run_main [0x4824de]
??:? main [0x460845]
??:? __libc_start_main [0x3958a439]
Program exited with code 1

Adding a dummy variable (aka the previous workaround)

~/dlang/inifiled on master [um] ± dub test
Generating test runner configuration 'inifiled-test-library' for 'library' (library).
Performing "unittest" build using dmd for x86_64.
inifiled 1.0.1: building configuration "inifiled-test-library"...
Linking...
Running ./inifiled-test-library
229 inifiled.StaticAnalysisConfig 7ffd81c36860
242 [inifiled.StaticAnalysisConfig] inifiled.StaticAnalysisConfig 1
242 style_check="disabled" inifiled.StaticAnalysisConfig 0
258 style_check disabled
242 [inifiled.ModuleFilters] inifiled.StaticAnalysisConfig 1
249 inifiled.ModuleFilters
250 7ffd81c36860
 229 inifiled.ModuleFilters 7ffd81c36860
 242 style_check = "+std.algorithm" inifiled.ModuleFilters 0
 258 style_check +std.algorithm
 242 foo = "" inifiled.ModuleFilters 0
 258 foo
242 foo = "" inifiled.StaticAnalysisConfig 0
258 foo
All unit tests have been run successfully.
``` #

@wilzbach wilzbach changed the title Fix overwrites of a key when occurring in the nested sectin as well Fix overwrites of a key when occurring in the nested section as well Jun 19, 2017
@wilzbach wilzbach force-pushed the fix-ini branch 2 times, most recently from 9d991ce to 23e2e5d Compare June 19, 2017 13:57
@wilzbach
Copy link
Contributor Author

the name is test/filename.ini in case you wouldn't have noticed the TravisCI failure.

Ah - I forgot to add the dscanner.ini - thanks!
Also removed the unrelated whitespace changes.
@burner: configuring your editor to avoid emitting trailing whitespace makes life easier ...

Copy link
Owner

@burner burner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other then the nitpicks the patch looks good.

enum Check : string { disabled = "disabled"}

@INI
struct StaticAnalysisConfig
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inifiled style differs from phobos. opening curly braces go on the previous line

}

version(unittest) {
enum Check : string { disabled = "disabled"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz replace 4 spaces by one tab

- dmd-beta
- dmd
- ldc-beta
- ldc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw Travis crons are highly useful: https://blog.travis-ci.com/2016-12-06-the-crons-are-here

- ldc
- dmd-2.069.0
- dmd-2.070.2
- dmd-2.071.2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis complains about older platforms:

inifiled 1.0.1+commit.3.gda4fa76: building configuration "inifiled-test-library"...
source/inifiled.d-mixin-253(255,1): Warning: switch case fallthrough - use 'goto default;' if intended
source/inifiled.d-mixin-253(255,1): Warning: switch case fallthrough - use 'goto case;' if intended
source/inifiled.d-mixin-253(256,1): Warning: switch case fallthrough - use 'goto default;' if intended
source/inifiled.d-mixin-253(255,1): Warning: switch case fallthrough - use 'goto default;' if intended
dmd failed with exit code 1.

Looks like a compiler error that has been fixed in 2.072 - is there any legitimate interest in supporting outdated releases? For the build scripts at dlang 2.072.2 is mostly used as "stable" DMD ...

@wilzbach
Copy link
Contributor Author

other then the nitpicks the patch looks good.

Done.
I also removed the CT warning about DMD's switch fallthroughs and simplified the generated section string if the section is empty.

@burner
Copy link
Owner

burner commented Jun 20, 2017

@wilzbach thanks

@burner burner merged commit 35f8d2d into burner:master Jun 20, 2017
@wilzbach wilzbach deleted the fix-ini branch June 20, 2017 07:26
@wilzbach
Copy link
Contributor Author

Thanks a lot for the fast feedback, merge & releasing a new version!

@burner
Copy link
Owner

burner commented Jun 20, 2017

already released a new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants