laguna-xs2-two-hacks / data /generated /shell_agent_tasks_batch_03.json
armantsaturian's picture
Add files using upload-large-folder tool
83d0913 verified
Raw
History Blame Contribute Delete
10.1 kB
{
"tasks": [
{
"id": "train_makefile_var_quotes_missing",
"split": "train",
"title": "Makefile Variable Expansion Quotes Missing",
"instruction": "The Makefile runs a shell command using a variable containing a file name with spaces, but the command fails when the file name has spaces. It should correctly handle file names with spaces.",
"files": {
"Makefile": "FILE=sample data.txt\nrun:\n\tcat $(FILE)\n",
"tests/test_makefile.py": "import subprocess\ndef test_makefile_runs_with_spaces():\n with open('sample data.txt', 'w') as f:\n f.write('ok')\n result = subprocess.run(['make', 'run'], capture_output=True)\n assert result.returncode == 0\n assert b'ok' in result.stdout\n"
},
"checks": [
{
"type": "contains",
"path": "Makefile",
"text": "cat \"$(FILE)\""
}
],
"failure_messages": [
"Makefile: cat: sample: No such file or directory"
],
"canonical_solution": "Wrap variable $(FILE) with quotes in the cat command, like cat \"$(FILE)\"."
},
{
"id": "train_shell_script_single_quotes_env_bug",
"split": "train",
"title": "Shell Script Environment Variable Quoting Error",
"instruction": "The shell script runs a command using a variable with spaces, but the value is not properly quoted, causing the command to fail if the variable contains spaces. It should work correctly with any value.",
"files": {
"scripts/run.sh": "#!/bin/sh\nDATA_FILE=$1\ncat $DATA_FILE\n",
"tests/test_run_sh.py": "import subprocess\ndef test_run_sh_with_spaces(tmp_path):\n f = tmp_path / 'data file.txt'\n f.write_text('data')\n result = subprocess.run(['sh', 'scripts/run.sh', str(f)], capture_output=True)\n assert result.returncode == 0\n assert b'data' in result.stdout\n"
},
"checks": [
{
"type": "contains",
"path": "scripts/run.sh",
"text": "cat \"$DATA_FILE\""
}
],
"failure_messages": [
"cat: data: No such file or directory"
],
"canonical_solution": "Quote $DATA_FILE in the cat command as \"$DATA_FILE\"."
},
{
"id": "train_js_package_script_quotes",
"split": "train",
"title": "JavaScript NPM Script Quotes Issue",
"instruction": "The package.json test script tries to echo a string with spaces, but it is split incorrectly because of missing quotes. The test should pass with the correct string output.",
"files": {
"package.json": "{\n \"scripts\": {\n \"test\": \"echo Hello World\"\n }\n}\n",
"tests/test_script_quotes.py": "import subprocess\ndef test_npm_script_quotes():\n result = subprocess.run(['npm', 'run', 'test'], capture_output=True)\n assert b'Hello World' in result.stdout\n"
},
"checks": [
{
"type": "contains",
"path": "package.json",
"text": "echo \"Hello World\""
}
],
"failure_messages": [
"Expected Hello World as output, but got multiple lines"
],
"canonical_solution": "Wrap Hello World in quotes in the echo command of the test script."
},
{
"id": "train_pathlib_mkdir_missing_parents",
"split": "train",
"title": "Pathlib Missing Parents When Writing File",
"instruction": "The Python script writes a file into a nested directory, but fails if the parent directory does not exist. It should create any missing parent directories automatically.",
"files": {
"src/write_data.py": "from pathlib import Path\n\ndef write():\n path = Path('data/output.txt')\n with path.open('w') as f:\n f.write('ok')\n",
"tests/test_write_data.py": "import src.write_data\ndef test_write():\n import shutil, os\n if os.path.exists('data'):\n shutil.rmtree('data')\n src.write_data.write()\n assert open('data/output.txt').read() == 'ok'\n"
},
"checks": [
{
"type": "contains",
"path": "src/write_data.py",
"text": "path.parent.mkdir(parents=True, exist_ok=True)"
}
],
"failure_messages": [
"FileNotFoundError: [Errno 2] No such file or directory: 'data/output.txt'"
],
"canonical_solution": "Insert path.parent.mkdir(parents=True, exist_ok=True) before opening the file."
},
{
"id": "train_py_cli_env_var_overrides",
"split": "train",
"title": "Python CLI Ignores Environment Variable Override",
"instruction": "The Python CLI should read a value from an environment variable and use it unless a command-line argument is given, but it currently ignores the environment variable.",
"files": {
"src/cli.py": "import argparse\nimport os\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument('--mode')\n args = parser.parse_args()\n mode = args.mode or 'default'\n print(mode)\nif __name__ == '__main__':\n main()\n",
"tests/test_cli.py": "import subprocess\ndef test_env_override():\n out = subprocess.check_output(['python', 'src/cli.py'], env={**dict(), 'MODE': 'prod'})\n assert b'prod' in out\n\ndef test_arg_takes_precedence():\n out = subprocess.check_output(['python', 'src/cli.py', '--mode', 'dev'], env={**dict(), 'MODE': 'prod'})\n assert b'dev' in out\n"
},
"checks": [
{
"type": "contains",
"path": "src/cli.py",
"text": "os.environ.get('MODE')"
},
{
"type": "regex",
"path": "src/cli.py",
"pattern": "mode\\s*=\\s*args\\.mode\\s*or\\s*os\\.environ\\.get\\(['\"]MODE['\"]\\)\\s*or\\s*['\"]default['\"]"
}
],
"failure_messages": [
"CLI prints 'default' instead of 'prod' when MODE env var is set.",
"CLI does not handle precedence order between --mode and MODE env var."
],
"canonical_solution": "Use mode = args.mode or os.environ.get('MODE') or 'default' to check the argument, then the environment, then the default."
},
{
"id": "train_js_package_script_env_var_quotes",
"split": "train",
"title": "JavaScript Script Fails With Spaces In Env Variable",
"instruction": "The NPM test script runs a node command using an environment variable containing spaces, but it does not handle the variable correctly. The script should work with values containing spaces.",
"files": {
"package.json": "{\n \"scripts\": {\n \"test\": \"NODE_VAR=hello world node printenv.js\"\n }\n}\n",
"printenv.js": "console.log(process.env.NODE_VAR);",
"tests/test_script_env_var.py": "import subprocess\ndef test_env_var():\n result = subprocess.run(['npm', 'run', 'test'], capture_output=True, text=True)\n assert 'hello world' in result.stdout\n"
},
"checks": [
{
"type": "contains",
"path": "package.json",
"text": "NODE_VAR=\"hello world\""
}
],
"failure_messages": [
"NODE_VAR is not set to 'hello world' in the node process."
],
"canonical_solution": "Wrap hello world in quotes in the NODE_VAR assignment in the script."
},
{
"id": "train_py_env_bool_str_bug",
"split": "train",
"title": "Python Reads Boolean Env Variable As String",
"instruction": "The Python module reads an environment variable as a boolean configuration, but it does not properly interpret 'false' or '0' as False. It should treat 'false', '0', and '' as False, and 'true', '1' as True (case-insensitive).",
"files": {
"src/config.py": "import os\ndef is_debug():\n return bool(os.environ.get('DEBUG'))\n",
"tests/test_config.py": "import os\nfrom src.config import is_debug\n\ndef test_false():\n os.environ['DEBUG'] = 'false'\n assert is_debug() is False\n os.environ['DEBUG'] = '0'\n assert is_debug() is False\n os.environ['DEBUG'] = ''\n assert is_debug() is False\n\ndef test_true():\n os.environ['DEBUG'] = 'true'\n assert is_debug() is True\n os.environ['DEBUG'] = '1'\n assert is_debug() is True\n"
},
"checks": [
{
"type": "contains",
"path": "src/config.py",
"text": ".lower()"
},
{
"type": "regex",
"path": "src/config.py",
"pattern": "return\\s*(os\\.environ\\.get\\(['\"]DEBUG['\"]\\)|debug)\\.lower\\(\\)\\s*in\\s*\\['?1'?,\\s*'?true'?\\]"
}
],
"failure_messages": [
"is_debug() returns True for DEBUG='false'",
"is_debug() does not recognize '1' and 'true' as True"
],
"canonical_solution": "Convert the env var to lowercase and check if it's in ['1','true'] for True, otherwise False."
},
{
"id": "eval_makefile_shell_var_sub_bug",
"split": "eval",
"title": "Makefile Shell Command Variable Substitution Bug",
"instruction": "The Makefile uses a shell command to assign a variable with the output of another command, but the variable is not substituted properly. It should assign the output of the command correctly.",
"files": {
"Makefile": "DATE = $(shell date +%Y-%m-%d)\nrun:\n\t@echo Date: $DATE\n",
"tests/test_makefile_date.py": "import subprocess, re\ndef test_date():\n out = subprocess.check_output(['make', 'run'], text=True)\n assert re.search(r'Date: \\d{4}-\\d{2}-\\d{2}', out)\n"
},
"checks": [
{
"type": "contains",
"path": "Makefile",
"text": "$(shell date +%Y-%m-%d)"
},
{
"type": "regex",
"path": "Makefile",
"pattern": "@echo Date: \\$\\(DATE\\)"
}
],
"failure_messages": [
"Makefile prints literal '$DATE' instead of the output of date.",
"Makefile echo command does not expand $(DATE)."
],
"canonical_solution": "Use $(DATE) for variable expansion, not $DATE, and ensure $(shell date +%Y-%m-%d) is used for the variable assignment."
}
]
}