From 28bd14d438affce02c87b7e7b108c3016feba6a4 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser <2466365+cschlosser@users.noreply.github.com> Date: Sat, 3 Oct 2020 19:43:04 +0200 Subject: Add env-var to replace env var in template strings (#175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add env-var to replace env var in template strings * Windows has it’s user in USERNAME --- src/test/CppTests/Config.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/test') diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts index 3915f11..d479d2d 100644 --- a/src/test/CppTests/Config.test.ts +++ b/src/test/CppTests/Config.test.ts @@ -227,4 +227,24 @@ suite("C++ - Configuration Tests", () => { assert.equal("/**\n * @note\n */", result); }); + test("Env variable", () => { + testSetup.cfg = new Config(); + testSetup.cfg.Generic.order = ["custom"]; + if (process.platform === "win32") { + testSetup.cfg.Generic.customTags = ["@author ${env:USERNAME}"]; + const res = testSetup.SetLine("void foo();").GetResult(); + // USERNAME env var is different for everybody + assert.notEqual("/**\n * @author USERNAME\n */", res); + } else { + testSetup.cfg.Generic.customTags = ["@author ${env:USER}"]; + const res = testSetup.SetLine("void foo();").GetResult(); + // USER env var is different for everybody + assert.notEqual("/**\n * @author USER\n */", res); + } + + testSetup.cfg.Generic.customTags = ["@author ${env:MY_VARIABLE}"]; + const result = testSetup.SetLine("void foo();").GetResult(); + assert.equal("/**\n * @author MY_VARIABLE\n */", result); + }); + }); -- cgit v1.2.3