Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2619ee

Browse files
committed
Make tests use pathlib2/pathlib as a start.
1 parentd7935b6 commitd2619ee

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

‎.pylintrc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ accept-no-yields-doc=no
2525
# --enable=similarities". If you want to run only the classes checker, but have
2626
# no Warning level messages displayed, use"--disable=all --enable=classes
2727
# --disable=W"
28-
disable=locally-disabled,no-absolute-import,suppressed-message,useless-suppression
28+
# Note: old-division can be removed once Python 2.7 gets EOL. It was interfering with pathlib2 usage
29+
# For all intents and purposes, all errors that old-division had pointed out were already fixed prior to pathlib2
30+
# It should be re-added to the enable= line below
31+
disable=locally-disabled,no-absolute-import,old-division,suppressed-message,useless-suppression
2932

3033
# Enable the message, report, category or checker with the given id(s). You can
3134
# either give multiple identifier separated by comma (,) or put this option
3235
# multiple time (only on the command line, not in the configuration file where
3336
# it should appear only once). See also the "--disable" option for examples.
34-
enable=apply-builtin,backtick,bad-inline-option,bad-python3-import,basestring-builtin,buffer-builtin,cmp-builtin,cmp-method,coerce-builtin,coerce-method,delslice-method,deprecated-pragma,deprecated-str-translate-call,deprecated-string-function,dict-iter-method,dict-view-method,div-method,eq-without-hash,exception-message-attribute,execfile-builtin,file-builtin,file-ignored,filter-builtin-not-iterating,getslice-method,hex-method,idiv-method,import-star-module-level,indexing-exception,input-builtin,intern-builtin,invalid-str-codec,locally-enabled,long-builtin,long-suffix,map-builtin-not-iterating,metaclass-assignment,next-method-called,nonzero-method,oct-method,old-division,old-ne-operator,old-octal-literal,old-raise-syntax,parameter-unpacking,print-statement,raising-string,range-builtin-not-iterating,raw-checker-failed,raw_input-builtin,rdiv-method,reduce-builtin,reload-builtin,round-builtin,setslice-method,standarderror-builtin,sys-max-int,unichr-builtin,unicode-builtin,unpacking-in-except,using-cmp-argument,xrange-builtin,zip-builtin-not-iterating
37+
enable=apply-builtin,backtick,bad-inline-option,bad-python3-import,basestring-builtin,buffer-builtin,cmp-builtin,cmp-method,coerce-builtin,coerce-method,delslice-method,deprecated-pragma,deprecated-str-translate-call,deprecated-string-function,dict-iter-method,dict-view-method,div-method,eq-without-hash,exception-message-attribute,execfile-builtin,file-builtin,file-ignored,filter-builtin-not-iterating,getslice-method,hex-method,idiv-method,import-star-module-level,indexing-exception,input-builtin,intern-builtin,invalid-str-codec,locally-enabled,long-builtin,long-suffix,map-builtin-not-iterating,metaclass-assignment,next-method-called,nonzero-method,oct-method,old-ne-operator,old-octal-literal,old-raise-syntax,parameter-unpacking,print-statement,raising-string,range-builtin-not-iterating,raw-checker-failed,raw_input-builtin,rdiv-method,reduce-builtin,reload-builtin,round-builtin,setslice-method,standarderror-builtin,sys-max-int,unichr-builtin,unicode-builtin,unpacking-in-except,using-cmp-argument,xrange-builtin,zip-builtin-not-iterating
3538

3639
[BASIC]
3740

‎setup.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"future>=0.16.0",
3535
"FuzzManager>=0.1.3",
3636
"lithium-reducer>=0.2.1",
37+
"pathlib2>=2.3.0",
3738
"psutil>=5.4.3",
3839
"pytest-cov>=2.5.1",
3940
"pytest-flake8>=1.0.0",

‎src/funfuzz/js/inspect_shell.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@ def shellSupports(shellPath, args): # pylint: disable=invalid-name,missing-para
132132
deftestBinary(shellPath,args,useValgrind):# pylint: disable=invalid-name,missing-param-doc,missing-return-doc
133133
# pylint: disable=missing-return-type-doc,missing-type-doc
134134
"""Test the given shell with the given args."""
135-
test_cmd= (constructVgCmdList()ifuseValgrindelse [])+ [shellPath]+args
136-
sps.vdump("The testing command is: "+sps.shellify(test_cmd))
135+
test_cmd= (constructVgCmdList()ifuseValgrindelse [])+ [str(shellPath)]+args
136+
#sps.vdump("The testing command is: " + sps.shellify(test_cmd))
137137
out,return_code=sps.captureStdout(test_cmd,combineStderr=True,ignoreStderr=True,
138-
ignoreExitCode=True,env=env_with_path(
139-
os.path.dirname(os.path.abspath(shellPath))))
138+
ignoreExitCode=True,env=env_with_path(str(shellPath.parent)))
140139
sps.vdump("The exit code is: "+str(return_code))
141140
returnout,return_code
142141

‎tests/js/test_compile_shell.py‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@
1010
from __future__importabsolute_import,unicode_literals
1111

1212
importlogging
13-
importos
14-
importpytest
13+
importplatform
14+
importsys
15+
importpytest# pylint: disable=wrong-import-order
1516

1617
importfunfuzz
1718

19+
ifsys.version_info.major==2:
20+
frompathlib2importPath
21+
else:
22+
frompathlibimportPath# pylint: disable=import-error
23+
1824
funfuzz_log=logging.getLogger("funfuzz_test")
1925
logging.basicConfig(level=logging.DEBUG)
2026
logging.getLogger("flake8").setLevel(logging.WARNING)
2127

28+
MC_HG_REPO=Path.home()/"trees"/"mozilla-central"
29+
SHELL_CACHE=Path.home()/"shell-cache"
30+
2231

2332
@pytest.mark.slow
2433
deftest_compile_shell_A_dbg():
2534
"""Test compilation of a debug shell with determinism, valgrind and OOM breakpoint support."""
26-
assertos.path.isdir(os.path.join(os.path.expanduser("~"),"trees","mozilla-central"))
35+
assertMC_HG_REPO.is_dir()# pylint: disable=no-member
2736
# Remember to update the expected binary filename
2837
build_opts= ("--enable-debug --disable-optimize --enable-more-deterministic "
2938
"--build-with-valgrind --enable-oom-breakpoint")
@@ -36,14 +45,18 @@ def test_compile_shell_A_dbg():
3645

3746
result=fz.run(["-b",build_opts])
3847
assertresult==0
48+
3949
file_name="js-dbg-optDisabled-64-dm-vg-oombp-linux-"+hg_hash_of_default
40-
assertos.path.isfile(os.path.join(
41-
os.path.expanduser("~"),"shell-cache",file_name,file_name))
50+
js_bin_path=SHELL_CACHE/file_name/file_name
51+
ifplatform.system()=="Windows":
52+
js_bin_path.with_suffix(".exe")
53+
assertjs_bin_path.is_file()
4254

4355

4456
@pytest.mark.slow
4557
deftest_compile_shell_B_opt():
4658
"""Test compilation of an opt shell with both profiling and Intl support disabled."""
59+
assertMC_HG_REPO.is_dir()# pylint: disable=no-member
4760
# Remember to update the expected binary filename
4861
build_opts= ("--disable-debug --disable-profiling --without-intl-api")
4962
# Change the repository location by uncommenting this line and specifying the right one
@@ -56,6 +69,9 @@ def test_compile_shell_B_opt():
5669
# This set of builds should also have the following: 32-bit with ARM, with asan, and with clang
5770
result=fz.run(["-b",build_opts])
5871
assertresult==0
72+
5973
file_name="js-64-profDisabled-intlDisabled-linux-"+hg_hash_of_default
60-
assertos.path.isfile(os.path.join(
61-
os.path.expanduser("~"),"shell-cache",file_name,file_name))
74+
js_bin_path=SHELL_CACHE/file_name/file_name
75+
ifplatform.system()=="Windows":
76+
js_bin_path.with_suffix(".exe")
77+
assertjs_bin_path.is_file()

‎tests/js/test_shell_flags.py‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,25 @@
1010
from __future__importabsolute_import,unicode_literals
1111

1212
importlogging
13-
importos
13+
importplatform
1414
importsys
1515

1616
importfunfuzz
1717

1818
ifsys.version_info.major==2:
1919
fromfunctools32importlru_cache# pylint: disable=import-error
20+
frompathlib2importPath
2021
else:
2122
fromfunctoolsimportlru_cache# pylint: disable=no-name-in-module
23+
frompathlibimportPath# pylint: disable=import-error
2224

2325
funfuzz_log=logging.getLogger("funfuzz_test")
2426
logging.basicConfig(level=logging.DEBUG)
2527
logging.getLogger("flake8").setLevel(logging.WARNING)
2628

29+
MC_HG_REPO=Path.home()/"trees"/"mozilla-central"
30+
SHELL_CACHE=Path.home()/"shell-cache"
31+
2732

2833
@lru_cache(maxsize=None)
2934
defget_current_shell_path():
@@ -32,7 +37,7 @@ def get_current_shell_path():
3237
Returns:
3338
str: Path to the compiled shell.
3439
"""
35-
assertos.path.isdir(os.path.join(os.path.expanduser("~"),"trees","mozilla-central"))
40+
assertMC_HG_REPO.is_dir()# pylint: disable=no-member
3641
# Remember to update the expected binary filename
3742
build_opts= ("--enable-debug --disable-optimize --enable-more-deterministic "
3843
"--build-with-valgrind --enable-oom-breakpoint")
@@ -41,9 +46,9 @@ def get_current_shell_path():
4146
build_opts_processed=funfuzz.js.build_options.parseShellOptions(build_opts)
4247
hg_hash_of_default=funfuzz.util.hg_helpers.getRepoHashAndId(build_opts_processed.repoDir)[0]
4348

44-
returnos.path.join(os.path.expanduser("~"),"shell-cache",
45-
"js-dbg-optDisabled-64-dm-vg-oombp-linux-"+hg_hash_of_default,
46-
"js-dbg-optDisabled-64-dm-vg-oombp-linux-"+hg_hash_of_default)
49+
file_name="js-dbg-optDisabled-64-dm-vg-oombp-linux-"+hg_hash_of_default
50+
js_bin_path=SHELL_CACHE/file_name/file_name
51+
returnjs_bin_path.with_suffix(".exe")ifplatform.system()=="Windows"elsejs_bin_path
4752

4853

4954
defmock_chance(i):
@@ -123,6 +128,11 @@ def test_add_random_wasm_flags(monkeypatch):
123128

124129
deftest_basic_flag_sets():
125130
"""Test that we are able to obtain a basic set of shell runtime flags for fuzzing."""
131+
# shell_cache = Path.home() / "shell-cache" # pylint: disable=old-division
132+
# # pylint: disable=old-division
133+
# shell_location = (shell_cache / ("js-dbg-optDisabled-64-dm-vg-oombp-linux-" + hg_hash_of_default) /
134+
# "js-dbg-optDisabled-64-dm-vg-oombp-linux-" + hg_hash_of_default)
135+
126136
important_flag_set= ["--fuzzing-safe","--no-threads","--ion-eager"]# Important flag set combination
127137
assertimportant_flag_setinfunfuzz.js.shell_flags.basic_flag_sets(get_current_shell_path())
128138

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp