Datasets:
Download environments/runtime-node-65621/v1/run-public.py from CrossSWE/CrossSWE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 6.75 kB
-
https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/environments/runtime-node-65621/v1/run-public.py
- Command line
-
hf download hf://datasets/CrossSWE/CrossSWE-Bench/environments/runtime-node-65621/v1/run-public.py
-
curl -L -o run-public.py https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/environments/runtime-node-65621/v1/run-public.py
6.75 kB
| """Unchanged upstream Node C-API and node-addon-api Object assertion programs. | |
| Compiles complete upstream native test modules against current paired headers. | |
| The addon bootstrap only registers upstream InitObject, with trace-only metadata. | |
| No evaluator/Gold/frozen test-patch material or production algorithm stub is used. | |
| """ | |
| from pathlib import Path | |
| import argparse,hashlib,json,os,re,shutil,subprocess | |
| NODE=Path('/testbed/nodejs/node');ADDON=Path('/testbed/nodejs/node-addon-api');HOME=Path(__file__).resolve().parent | |
| BASES={str(NODE):'5ed55ba0b82019f32aaa1a2ea01cd6627834ab16',str(ADDON):'25f7ba08642611556f3e5d10b0cfb125cdf275df'} | |
| def sha(p):return hashlib.sha256(Path(p).read_bytes()).hexdigest() | |
| def snapshot(): | |
| result={} | |
| for name,base in BASES.items(): | |
| root=Path(name);head=subprocess.check_output(['git','-C',name,'rev-parse','HEAD'],text=True).strip();subprocess.run(['git','-C',name,'merge-base','--is-ancestor',base,head],check=True) | |
| files=subprocess.check_output(['git','-C',name,'ls-files','--cached','--others','--exclude-standard','-z']).split(b'\0');rows=[] | |
| for raw in files: | |
| if not raw:continue | |
| p=root/os.fsdecode(raw) | |
| if p.is_symlink():data=os.fsencode(os.readlink(p)) | |
| elif p.is_file():data=p.read_bytes() | |
| else:continue | |
| rows.append([os.fsdecode(raw),hashlib.sha256(data).hexdigest()]) | |
| result[name]={'base_commit':base,'head':head,'working_source_manifest_sha256':hashlib.sha256(json.dumps(rows).encode()).hexdigest()} | |
| return result | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--output',default='/tmp/crossswe-public-object-report');a=p.parse_args();out=Path(a.output);out.mkdir(parents=True,exist_ok=False);before=snapshot();steps=[] | |
| def run(label,args,cwd=NODE,env=None,check=True): | |
| with(out/(label+'.stdout.raw')).open('wb')as o,(out/(label+'.stderr.raw')).open('wb')as e:q=subprocess.run(args,cwd=cwd,env=env,stdout=o,stderr=e,timeout=3600) | |
| record={'label':label,'argv':[str(x)for x in args],'cwd':str(cwd),'returncode':q.returncode,'stdout_sha256':sha(out/(label+'.stdout.raw')),'stderr_sha256':sha(out/(label+'.stderr.raw'))};steps.append(record);(out/'steps.json').write_text(json.dumps(steps,indent=2)+'\n');assert not check or q.returncode==0,label;return q.returncode | |
| compiler=['CXX=/usr/bin/clang++-19','CC=/usr/bin/clang-19','CXX.host=/usr/bin/clang++-19','CC.host=/usr/bin/clang-19'] | |
| runtime=NODE/'out/Release/node';run('build-current-node-runtime',['make','-C','out','BUILDTYPE=Release','V=1',*compiler,'-j16',str(runtime)]) | |
| assert runtime.is_file();installed=Path('/usr/local/bin/node') | |
| if installed.is_symlink():installed.unlink() | |
| if not installed.exists()or sha(installed)!=sha(runtime):shutil.copy2(runtime,installed) | |
| node_binding=NODE/'test/js-native-api/test_object/build/Release/test_object.node';node_binding.parent.mkdir(parents=True,exist_ok=True) | |
| sources=[NODE/'test/js-native-api/test_object/test_object.c',NODE/'test/js-native-api/test_object/test_null.c'] | |
| run('build-current-upstream-C-object-tests',['clang-19','-shared','-fPIC','-DNAPI_EXPERIMENTAL','-DNODE_GYP_MODULE_NAME=test_object','-I'+str(NODE/'src'),*[str(x)for x in sources],'-o',str(node_binding)]) | |
| common=['-std=c++17','-shared','-fPIC','-DNAPI_EXPERIMENTAL','-DNAPI_VERSION=2147483647','-I'+str(ADDON),'-I'+str(ADDON/'test/common'),'-I'+str(NODE/'src'),'-I'+str(NODE/'deps/v8/include')] | |
| variants={'binding':['-DNAPI_CPP_EXCEPTIONS','-DNODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS'],'binding_noexcept':['-DNAPI_DISABLE_CPP_EXCEPTIONS','-fno-exceptions'],'binding_noexcept_maybe':['-DNAPI_DISABLE_CPP_EXCEPTIONS','-DNODE_ADDON_API_ENABLE_MAYBE','-fno-exceptions'],'binding_custom_namespace':['-DNAPI_DISABLE_CPP_EXCEPTIONS','-DNAPI_CPP_CUSTOM_NAMESPACE=cstm','-fno-exceptions']} | |
| addon_sources=sorted((ADDON/'test/object').glob('*.cc'));build=ADDON/'test/build/Release';build.mkdir(parents=True,exist_ok=True);bindings=[] | |
| for name,flags in variants.items(): | |
| target=build/(name+'.node');run('build-upstream-object-'+name,['clang++-19',*common,*flags,'-DNODE_GYP_MODULE_NAME='+name,'-DCROSSSWE_PUBLIC_VARIANT="'+name+'"',str(HOME/'addon-object-public-bootstrap.cc'),*[str(x)for x in addon_sources],'-o',str(target)],cwd=ADDON);bindings.append({'variant':name,'path':str(target),'sha256':sha(target)}) | |
| node_test=NODE/'test/js-native-api/test_object/test.js';addon_test=ADDON/'test/object/object.js';trace=out/'native-binding-configurations.jsonl';env=dict(os.environ,CROSSSWE_PUBLIC_BINDING_TRACE=str(trace),NODE_API_BUILD_CONFIG='Release') | |
| results=[] | |
| for key,test,cwd in [('node',node_test,NODE),('addon',HOME/'addon-object-public-driver.js',ADDON)]: | |
| rc=run('actual-public-'+key,[str(runtime),'--test','--test-reporter=tap',str(test)],cwd=cwd,env=env,check=False);raw=(out/('actual-public-'+key+'.stdout.raw')).read_text(errors='replace');metrics={k:int(v)for k,v in re.findall(r'^# (tests|pass|fail|cancelled|skipped|todo) (\d+)$',raw,re.M)} | |
| results.append({'repository':key,'kind':'upstream-public'if key=='node'else'upstream-public-with-public-module-registration','case_unit':'Actual Node test-runner assertion program; nested assertions/configuration executions are not extra test designs.','executed':metrics.get('tests',0),'passed':metrics.get('pass',0),'failed':metrics.get('fail',0),'skipped':metrics.get('skipped',0),'cancelled':metrics.get('cancelled',0),'returncode':rc,'upstream_test':str(node_test if key=='node'else addon_test),'upstream_test_sha256':sha(node_test if key=='node'else addon_test)}) | |
| after=snapshot();assert before==after,'public tests changed candidate source';observed=trace.read_text().splitlines()if trace.exists()else[];good=all(r['returncode']==0 and r['executed']==r['passed']==1 and r['failed']==r['skipped']==r['cancelled']==0 for r in results)and sorted(observed)==sorted(variants) | |
| receipt={'state':'BOTH_REPOSITORIES_MEANINGFUL_PUBLIC_OBJECT_TESTS_PASSED'if good else'PUBLIC_OBJECT_TEST_OR_NATIVE_BUILD_HOLD','repositories':results,'source_before':before,'source_after':after,'source_unchanged':True,'runtime':{'path':str(runtime),'sha256':sha(runtime),'installed_copy_sha256':sha(installed)},'headers':{str(p):sha(p)for p in [NODE/'src/js_native_api.h',NODE/'src/js_native_api_v8.cc',ADDON/'napi.h',ADDON/'napi-inl.h']},'native_binding_configurations_observed':observed,'native_bindings':bindings,'scope':'Unchanged upstream C-API object/property/prototype assertions and unchanged upstream C++ Object assertions across four original configurations. Bootstrap registers complete actual upstream object test sources; no business stubs or extracted production functions.'} | |
| (out/'receipt.json').write_text(json.dumps(receipt,indent=2)+'\n');print(json.dumps(receipt));return 0 if good else 1 | |
| if __name__=='__main__':raise SystemExit(main()) | |