code: def test_placeholders(path=None):
      ds = Dataset(path).create(force=True)
      ds.save()
      assert_repo_status(ds.path)
      # ATTN windows is sensitive to spaces before redirect symbol
      ds.run(
          "echo {inputs}>{outputs}",
          inputs=[".", "*.in"],
          outputs=["c.out"],
      )
      ok_file_has_content(op.join(path, "c.out"), "a.in b.in\n")
  
      hexsha_before = ds.repo.get_hexsha()
      ds.rerun()
      eq_(hexsha_before, ds.repo.get_hexsha())
  
      # ATTN windows is sensitive to spaces before redirect symbol
      ds.run("echo {inputs[0]}>getitem", inputs=["*.in"])
      ok_file_has_content(op.join(path, "getitem"), "a.in\n")
  
      ds.run("echo {pwd} >expanded-pwd")
      ok_file_has_content(
          op.join(path, "expanded-pwd"), path, strip=True
      )
  
      ds.run("echo {dspath} >expanded-dspath")
      ok_file_has_content(
          op.join(path, "expanded-dspath"), ds.path, strip=True
      )
  
      subdir_path = op.join(path, "subdir")
      with chpwd(subdir_path):
          run("echo {pwd} >expanded-pwd")
      ok_file_has_content(
          op.join(path, "subdir", "expanded-pwd"),
          subdir_path,
          strip=True,
      )
      eq_(
          get_run_info(ds, last_commit_msg(ds.repo))[1]["pwd"], "subdir"
      )
  
      # Double brackets can be used to escape placeholders.
      ds.run("cd .> {{inputs}}", inputs=["*.in"])
      ok_exists(op.join(path, "{inputs}"))
  
      # rerun --script expands the placeholders.
      with patch("sys.stdout", new_callable=StringIO) as cmout:
          ds.rerun(script="-", since="")
          script_out = cmout.getvalue()
          assert_in("echo a.in b.in>c.out", script_out)
          assert_in(
              "echo {} >expanded-pwd".format(subdir_path), script_out
          )
          assert_in(
              "echo {} >expanded-dspath".format(ds.path), script_out
          )
  
      assert_result_count(
          ds.run("{unknown_placeholder}", on_failure="ignore"),
          1,
          status="impossible",
          action="run",
      )
  
      # Configured placeholders.
      ds.config.add(
          "datalad.run.substitutions.license", "gpl3", scope="local"
      )
      ds.run("echo {license} >configured-license")
      ok_file_has_content(
          op.join(path, "configured-license"), "gpl3", strip=True
      )
      # --script handles configured placeholders.
      with patch("sys.stdout", new_callable=StringIO) as cmout:
          ds.rerun(script="-")
          assert_in("gpl3", cmout.getvalue())
  
      ds.run("echo {tmpdir} >tout")
      ok_file_has_content(
          op.join(path, "tout"), ".*datalad-run.*", re_=True
      )
  
imports: import logging
  import os.path
  import sys
  from io import StringIO
  from os import remove
  import pytest
  from unittest.mock import patch
  from datalad.api import install, run
  from datalad.core.local.run import run_command
  from datalad.core.local.tests.test_run import last_commit_msg
  from datalad.distribution.dataset import Dataset
  from datalad.local.rerun import diff_revision, get_run_info, new_or_modified
  from datalad.support.exceptions import CommandError, IncompleteResultsError
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_dict_equal, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, neq_, ok_, ok_exists, ok_file_has_content, ok_file_under_git, skip_if_adjusted_branch, slow, swallow_logs, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd, on_windows
label_desc: Use image node_id 19 for calling a global function with example usage: test_placeholders(path) without return types