diff --git a/.plzconfig b/.plzconfig index 9337fda3..d3a6ce37 100644 --- a/.plzconfig +++ b/.plzconfig @@ -4,9 +4,6 @@ Version = >=17.12.2 [Build] hashcheckers = sha256 -[Parse] -PreloadBuildDefs = test/build_defs/test.build_defs - [Plugin "go"] Target = //plugins:go ImportPath = github.com/please-build/python-rules @@ -19,6 +16,9 @@ DisableVendorFlags = true [Plugin "shell"] Target = //plugins:shell +[Plugin "e2e"] +Target = //plugins:e2e + [PluginDefinition] name = python diff --git a/plugins/BUILD b/plugins/BUILD index 9d1da4a4..5f9a1301 100644 --- a/plugins/BUILD +++ b/plugins/BUILD @@ -7,3 +7,9 @@ plugin_repo( name = "shell", revision = "v0.1.2", ) + +plugin_repo( + name = "e2e", + plugin = "plugin-integration-testing", + revision = "v1.0.3", +) diff --git a/test/BUILD b/test/BUILD index 2346c070..fd167dbc 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,4 +1,8 @@ -subinclude("//build_defs:python", "///shell//build_defs:shell") +subinclude( + "///e2e//build_defs:e2e", + "///shell//build_defs:shell", + "//build_defs:python", +) package( default_visibility = ["PUBLIC"], diff --git a/test/build_defs/test.build_defs b/test/build_defs/test.build_defs deleted file mode 100644 index ae4ecae3..00000000 --- a/test/build_defs/test.build_defs +++ /dev/null @@ -1,59 +0,0 @@ -# Like please_repo_e2e_test, this runs end-to-end tests on Please itself but in the actual please repo. -def plz_e2e_test(name:str, cmd:str, pre_cmd:str=None, expected_output:str=None, - expected_failure:bool=False, expect_output_contains:str=None, - expect_output_doesnt_contain:str=None, deps:list=None, data:list=[], - labels:list=None, completion:bool=False, - expect_file_exists:str=None, expect_file_doesnt_exist:str=None, timeout:int=None): - # Please isn't really designed to work this way (running a test against the entire source repo) - # but we can make it do it and it's a convenient way of testing the tool itself. - - def _e2e_test_cmd(cmd): - args = '$PLZ_ARGS --noupdate -o sandbox.test:false -o sandbox.build:false -o sandbox.namespace:false ' - if package_name().startswith('test/parse'): - args += ' -o parse.buildfilename:BUILD,BUILD.plz,BUILD.test ' - cmd = cmd.replace('plz ', f'$TOOLS --nolock {args} -o cache.dirclean:false --log_file plz-out/log/{name}.log ') - if expected_failure: - test_cmd = '%s 2>&1 | tee output; if [ $? -eq 0 ]; then exit 1; fi; ' % cmd - else: - test_cmd = '%s 2>&1 | grep -v -e "grep" -e "determine version" -e "Downloading Please" -e "Should be good" | tee output && ' % cmd - if expected_output and expect_output_contains: - raise ValueError('Can only pass one of expected_output and expect_output_contains') - elif expected_output: - test_cmd += 'diff -au output $(location %s)' % expected_output - elif expect_output_contains: - test_cmd += 'if ! grep -q "%s" output; then cat output; exit 1; fi' % expect_output_contains - elif expect_output_doesnt_contain: - test_cmd += 'if grep -q "%s" output; then cat output; exit 1; fi' % expect_output_doesnt_contain - elif expect_file_exists: - test_cmd += 'if [ ! -f %s ]; then cat output; exit 1; fi' % expect_file_exists - elif expect_file_doesnt_exist: - test_cmd += 'if [ -f %s ]; then cat output; exit 1; fi' % expect_file_doesnt_exist - else: - test_cmd += 'true' - if completion: - test_cmd = "export GO_FLAGS_COMPLETION=1; " + test_cmd - if pre_cmd: - test_cmd = pre_cmd + ' && ' + test_cmd - return test_cmd - - - if expected_output: - data += [expected_output] - gentest( - name = name, - test_cmd = { - 'opt': _e2e_test_cmd(cmd), - 'dbg': _e2e_test_cmd(cmd.replace('plz ', 'plz -c dbg ')), - 'cover': _e2e_test_cmd(cmd.replace('plz ', 'plz -c cover ')), - }, - data = data, - deps = deps, - test_tools = ["//:please"], - labels = ['e2e'] + (labels or []), - no_test_output = True, - sandbox = False, - local = True, - pass_env = ["PLZ_ARGS"], - exit_on_error = False, - timeout = timeout, - )