ソースファイル関連

凡例
対応コードあり
直接対応していないが代替の書き方あり
対応コードなし
-未確認
( .. )ローカライズまだ
Example Python
pytest
PHP
PHPUnit
Swift
Testing
Csharp
xunit
Bash
bats
Powershell
pester
C++
GoogleTest
JavaScript
Jest
Kotlin
jUnit
実行時のコマンド名(パス)を取得 sys.argv[0] => ./a.py $argv[0] - - $0 => ./a.sh $PSCommandPath - - -
ソースファイル名(パス)を取得 __file__ __FILE__ - - ${BASH_SOURCE[0]} Get-Command .. ScriptBlock.File - - -
ソースファイルのディレクトリ名を取得 os.path.dirname(__file__) __DIR__ - - - $PSScriptRoot - - -
( get_executed_interpreter_path ) sys.executable PHP_BINARY - - - (Get-Process -Id $PID).Path - - -
( get_module_name ) __name__ - - - - - - - -
( get_current_directory ) os.getcwd() getcwd() - - - Get-Location - - -
( get_current_line_number ) inspect.currentframe().f_lineno - - - - - - - -
( get_caller_line_number ) inspect.currentframe().f_back.f_lineno - - - - - - - -
( get_current_function_name ) inspect.currentframe().f_code.co_name - - - - $MyInvocation.MyCommand.Name - - -
( get_caller_function_name ) inspect.currentframe().f_back.f_code.co_name - - - - Get-PSCallStack - - -
( get_current_file_name ) inspect.currentframe().f_code.co_filename - - - - - - - -
( get_caller_file_name ) inspect.currentframe().f_back.f_code.co_filename - - - - - - - -
( execute_when_its_main ) - if (realpath($argv[0]) === __FILE__) { - - - - - - -
( get_executed_command_path_when_called_from_another_script ) - - - - - $PSCommandPath - - -
( get_source_file_path_when_called_from_another_script ) - - - - - Get-Command .. ScriptBlock.File - - -
( get_current_file_path ) - - - - - $PSCommandPath - - -
( get_caller_file_path ) - - - - - Get-PSCallStack - - -