@@ -5,9 +5,7 @@ import * as assert from "assert";
55
66import { buildNoConfigPathAppendValue } from "../src/pathUtil" ;
77
8- // Regression tests for issue #1637: the extension was appending its
9- // noConfigScripts directory to PATH without a separator on some terminal
10- // PATH configurations, gluing it onto the last entry of the user's PATH.
8+ // Regression tests for issue #1637.
119suite ( "buildNoConfigPathAppendValue" , ( ) => {
1210
1311 const winDir = "C:\\Users\\me\\.vscode\\extensions\\vscjava.vscode-java-debug-0.59.0\\bundled\\scripts\\noConfigScripts" ;
@@ -30,69 +28,38 @@ suite("buildNoConfigPathAppendValue", () => {
3028
3129 test ( "always starts with a path separator (Windows)" , ( ) => {
3230 const result = buildNoConfigPathAppendValue ( winDir , "win32" ) ;
33- assert . ok ( result . startsWith ( ";" ) , `expected leading ';', got: ${ result } ` ) ;
31+ assert . ok ( result . startsWith ( ";" ) ) ;
3432 } ) ;
3533
3634 test ( "always starts with a path separator (POSIX)" , ( ) => {
3735 const result = buildNoConfigPathAppendValue ( posixDir , "linux" ) ;
38- assert . ok ( result . startsWith ( ":" ) , `expected leading ':', got: ${ result } ` ) ;
36+ assert . ok ( result . startsWith ( ":" ) ) ;
3937 } ) ;
4038
4139 test ( "never collapses scriptsDir into the previous PATH entry on Windows" , ( ) => {
42- // Simulates the exact scenario from issue #1637: a user PATH whose
43- // last entry has no trailing separator. After append, the script dir
44- // must not be glued onto 'jreleaser\'.
40+ // #1637 scenario: last user PATH entry has no trailing separator.
4541 const userPath = "C:\\foo;C:\\Program Files\\jreleaser\\" ;
46- const finalPath = userPath + buildNoConfigPathAppendValue ( winDir , "win32" ) ;
47-
48- const entries = finalPath . split ( ";" ) ;
49- assert . ok (
50- entries . includes ( "C:\\Program Files\\jreleaser\\" ) ,
51- `expected 'jreleaser\\' to remain a standalone PATH entry, got entries: ${ JSON . stringify ( entries ) } ` ,
52- ) ;
53- assert . ok (
54- entries . includes ( winDir ) ,
55- `expected scripts dir to be a standalone PATH entry, got entries: ${ JSON . stringify ( entries ) } ` ,
56- ) ;
42+ const entries = ( userPath + buildNoConfigPathAppendValue ( winDir , "win32" ) ) . split ( ";" ) ;
43+ assert . ok ( entries . includes ( "C:\\Program Files\\jreleaser\\" ) ) ;
44+ assert . ok ( entries . includes ( winDir ) ) ;
5745 } ) ;
5846
5947 test ( "never collapses scriptsDir into the previous PATH entry on POSIX" , ( ) => {
6048 const userPath = "/usr/bin:/opt/jreleaser/bin" ;
61- const finalPath = userPath + buildNoConfigPathAppendValue ( posixDir , "linux" ) ;
62-
63- const entries = finalPath . split ( ":" ) ;
64- assert . ok (
65- entries . includes ( "/opt/jreleaser/bin" ) ,
66- `expected '/opt/jreleaser/bin' to remain a standalone PATH entry, got entries: ${ JSON . stringify ( entries ) } ` ,
67- ) ;
68- assert . ok (
69- entries . includes ( posixDir ) ,
70- `expected scripts dir to be a standalone PATH entry, got entries: ${ JSON . stringify ( entries ) } ` ,
71- ) ;
49+ const entries = ( userPath + buildNoConfigPathAppendValue ( posixDir , "linux" ) ) . split ( ":" ) ;
50+ assert . ok ( entries . includes ( "/opt/jreleaser/bin" ) ) ;
51+ assert . ok ( entries . includes ( posixDir ) ) ;
7252 } ) ;
7353
7454 test ( "yields only an empty (harmless) entry when the user's PATH already ends with a separator" , ( ) => {
75- // If the resolved terminal PATH already ends with ';', append produces
76- // ';;'. The empty middle entry is ignored by Windows and (in this
77- // position) effectively a no-op on POSIX shells.
7855 const userPath = "C:\\foo;C:\\bar;" ;
79- const finalPath = userPath + buildNoConfigPathAppendValue ( winDir , "win32" ) ;
80-
81- const entries = finalPath . split ( ";" ) ;
82- // The scripts dir must still be a standalone, valid entry.
83- assert . ok (
84- entries . includes ( winDir ) ,
85- `expected scripts dir to remain standalone, got entries: ${ JSON . stringify ( entries ) } ` ,
86- ) ;
87- // No real entry should be merged with our scripts dir.
88- assert . ok (
89- ! entries . some ( ( e ) => e !== winDir && e . endsWith ( winDir ) ) ,
90- `no entry should be glued to scripts dir, got entries: ${ JSON . stringify ( entries ) } ` ,
91- ) ;
56+ const entries = ( userPath + buildNoConfigPathAppendValue ( winDir , "win32" ) ) . split ( ";" ) ;
57+ assert . ok ( entries . includes ( winDir ) ) ;
58+ assert . ok ( ! entries . some ( ( e ) => e !== winDir && e . endsWith ( winDir ) ) ) ;
9259 } ) ;
9360
9461 test ( "scriptsDir appears unchanged at the end of the appended value" , ( ) => {
9562 const result = buildNoConfigPathAppendValue ( winDir , "win32" ) ;
96- assert . ok ( result . endsWith ( winDir ) , `expected value to end with scriptsDir, got: ${ result } ` ) ;
63+ assert . ok ( result . endsWith ( winDir ) ) ;
9764 } ) ;
9865} ) ;
0 commit comments