// SPDX-License-Identifier: MIT package executor import ( "os" "path/filepath" "reflect" "strings" "syscall" "testing" "time" ) // Cases ported from SetEnvFileCommandL0, SetOutputFileCommandL0 and // SaveStateFileCommandL0 (actions/runner, src/Test/L0/Worker). The C# tests // write their files with a UTF-8 BOM and join lines with the platform newline; // "\n" is used here and the BOM is added by writeEnvFile. func TestParseEnvFile(t *testing.T) { type kv = Pair tests := []struct { name string in string want []kv wantErr string }{ {"empty file", "", nil, ""}, {"simple", "MY_ENV=MY VALUE", []kv{{"MY_ENV", "MY VALUE"}}, ""}, {"skip empty lines", "\nMY_ENV=my value\n\nMY_ENV_2=my second value\n", []kv{{"MY_ENV", "my value"}, {"MY_ENV_2", "my second value"}}, ""}, {"empty value", "MY_ENV=", []kv{{"MY_ENV", ""}}, ""}, {"multiple values", "MY_ENV=my value\nMY_ENV_2=\nMY_ENV_3=my third value", []kv{{"MY_ENV", "my value"}, {"MY_ENV_2", ""}, {"MY_ENV_3", "my third value"}}, ""}, {"special characters", "MY_ENV==abc\nMY_ENV_2=def=ghi\nMY_ENV_3=jkl=", []kv{{"MY_ENV", "=abc"}, {"MY_ENV_2", "def=ghi"}, {"MY_ENV_3", "jkl="}}, ""}, {"heredoc", "MY_ENV<