Home > other >  Setting Test Environment Variables With Vala and Meson
Setting Test Environment Variables With Vala and Meson

Time:08-25

Hello Stackoverflow Community,

So I am trying to set environment vars for a database test in a vala project, but I can't find evidence of the variable anywhere. I also tried setting command line args but I couldnt access those either.

In my meson.build file:

test(test_db, test_db_exe, args : ['some_arg'], env : ['var1=some_env_arg'])

I then print out both my env vars and arguments with the following code:

 foreach (string va in GLib.Environment.list_variables()){
    GLib.Test.message(va);
}
foreach (string va in args){
    GLib.Test.message(va);
}

I don't see any evidence of these vars anywhere!

Here is the output of the test showing the environment variables and command line arguments printed to stdout:

─$ ./test-db                            
# POWERSHELL_TELEMETRY_OPTOUT
# USER
# XDG_SEAT
# XDG_SESSION_TYPE
# DOTNET_CLI_TELEMETRY_OPTOUT
# SSH_AGENT_PID
# HOME
# DESKTOP_SESSION
# XDG_SEAT_PATH
# GTK_MODULES
# DBUS_SESSION_BUS_ADDRESS
# COMMAND_NOT_FOUND_INSTALL_PROMPT
# QT_QPA_PLATFORMTHEME
# LOGNAME
# QT_AUTO_SCREEN_SCALE_FACTOR
# XDG_SESSION_CLASS
# XDG_SESSION_ID
# PATH
# GDM_LANG
# _JAVA_OPTIONS
# XDG_SESSION_PATH
# XDG_RUNTIME_DIR
# XDG_MENU_PREFIX
# LANG
# POWERSHELL_UPDATECHECK
# XDG_CURRENT_DESKTOP
# XDG_SESSION_DESKTOP
# XAUTHORITY
# XDG_GREETER_DATA_DIR
# SSH_AUTH_SOCK
# SHELL
# GDMSESSION
# QT_ACCESSIBILITY
# XDG_VTNR
# PWD
# XDG_DATA_DIRS
# XDG_CONFIG_DIRS
# SESSION_MANAGER
# PANEL_GDK_CORE_DEVICE_EVENTS
# DISPLAY
# CHROME_DESKTOP
# ORIGINAL_XDG_CURRENT_DESKTOP
# GDK_BACKEND
# SHLVL
# OLDPWD
# LESS_TERMCAP_mb
# LESS_TERMCAP_md
# LESS_TERMCAP_me
# LESS_TERMCAP_so
# LESS_TERMCAP_se
# LESS_TERMCAP_us
# LESS_TERMCAP_ue
# _
# BREAKPAD_DUMP_LOCATION
# TERM_PROGRAM
# TERM_PROGRAM_VERSION
# COLORTERM
# VSCODE_GIT_IPC_HANDLE
# GIT_ASKPASS
# VSCODE_GIT_ASKPASS_NODE
# VSCODE_GIT_ASKPASS_MAIN
# TERM
# LS_COLORS
# ./test-db

CodePudding user response:

You need to be looking in the meson-logs directory of your build directory. For my tests, stdout appears in testlog.txt.

  • Related