1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ import * as assert from 'assert' ;
7+ import { shellExec } from './testUtils' ;
8+
9+ describe ( 'Fish shell integration' , function ( ) {
10+ this . timeout ( '30s' ) ;
11+
12+ it ( 'should successfully read environment variables with fish shell' , async ( ) => {
13+ // Test the actual fish shell command construction
14+ const testCommand = `echo -n START; echo 'TEST_VAR=test_value'; echo -n END` ;
15+
16+ // Test the problematic case without quoting (should fail)
17+ const unquotedCommand = `fish -lic ${ testCommand } ` ;
18+
19+ // Test the fixed case with quoting (should work)
20+ const quotedCommand = `fish -lic '${ testCommand . replace ( / ' / g, `'\\''` ) } '` ;
21+
22+ try {
23+ // This test requires fish to be installed
24+ await shellExec ( 'fish --version' , { } , true , true ) ;
25+
26+ // Test the unquoted command (should show warning/error)
27+ const unquotedResult = await shellExec ( unquotedCommand , { } , true , true ) ;
28+
29+ // The unquoted command should either fail or show a warning
30+ const hasWarning = unquotedResult . stderr . includes ( 'Can not use the no-execute mode' ) ||
31+ unquotedResult . stderr . includes ( 'warning' ) ||
32+ unquotedResult . error !== null ;
33+
34+ // Test the quoted command (should work)
35+ const quotedResult = await shellExec ( quotedCommand , { } , true , true ) ;
36+
37+ // The quoted command should work without warnings
38+ assert . ok ( quotedResult . error === null , 'Quoted command should not error' ) ;
39+ assert . ok ( quotedResult . stdout . includes ( 'START' ) , 'Should contain START marker' ) ;
40+ assert . ok ( quotedResult . stdout . includes ( 'END' ) , 'Should contain END marker' ) ;
41+ assert . ok ( quotedResult . stdout . includes ( 'TEST_VAR=test_value' ) , 'Should contain test environment variable' ) ;
42+
43+ // At least one of the following should be true:
44+ // 1. The unquoted command shows a warning or error
45+ // 2. The quoted command works better (more complete output)
46+ const quotedOutputComplete = quotedResult . stdout . includes ( 'START' ) &&
47+ quotedResult . stdout . includes ( 'END' ) &&
48+ quotedResult . stdout . includes ( 'TEST_VAR=test_value' ) ;
49+
50+ assert . ok ( hasWarning || quotedOutputComplete , 'Either unquoted command should warn or quoted command should work better' ) ;
51+
52+ } catch ( error ) {
53+ // If fish is not installed, skip this test
54+ console . log ( 'Fish shell not available, skipping integration test' ) ;
55+ }
56+ } ) ;
57+ } ) ;
0 commit comments