From 24cb9851fe829777c1073781ef014a0c7b0336b0 Mon Sep 17 00:00:00 2001 From: Nizar Date: Sun, 17 Mar 2024 21:59:13 +0400 Subject: [PATCH] Add maxdepth input test (#35) --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++-- tests/maxdepth/main.expected.js | 1 + tests/maxdepth/main.js | 7 +++++++ tests/maxdepth/not-affected/main.js | 7 +++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/maxdepth/main.expected.js create mode 100644 tests/maxdepth/main.js create mode 100644 tests/maxdepth/not-affected/main.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 128df11..6b8e510 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: - name: Test on affected directory uses: ./ with: - directory: "tests/directory/affected/*" + directory: "tests/directory/affected" - name: Assert not affected result does not exist run: | @@ -30,6 +30,29 @@ jobs: tests/directory/affected/main.expected.js \ tests/directory/affected/main.min.js + maxdepth: + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Test on shallow maxdepth + uses: ./ + with: + directory: "tests/maxdepth" + maxdepth: 1 + + - name: Assert shallow result matches expected + run: | + git diff --exit-code --no-index \ + tests/maxdepth/main.expected.js \ + tests/maxdepth/main.min.js + + - name: Assert deep result does not exist + run: | + ! test -e tests/maxdepth/not-affected/main.min.js + overwrite: runs-on: ubuntu-latest @@ -40,7 +63,7 @@ jobs: - name: Test overwrite uses: ./ with: - directory: "tests/overwrite/*" + directory: "tests/overwrite" overwrite: true - name: Assert overwrite result matches expected diff --git a/tests/maxdepth/main.expected.js b/tests/maxdepth/main.expected.js new file mode 100644 index 0000000..28e60c1 --- /dev/null +++ b/tests/maxdepth/main.expected.js @@ -0,0 +1 @@ +function print_hello(){console.log("hello world from maxdepth")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/maxdepth/main.js b/tests/maxdepth/main.js new file mode 100644 index 0000000..953dc64 --- /dev/null +++ b/tests/maxdepth/main.js @@ -0,0 +1,7 @@ +function print_hello() { + console.log('hello world from maxdepth'); +} + +window.addEventListener('load', function () { + print_hello(); +}); diff --git a/tests/maxdepth/not-affected/main.js b/tests/maxdepth/not-affected/main.js new file mode 100644 index 0000000..f63074b --- /dev/null +++ b/tests/maxdepth/not-affected/main.js @@ -0,0 +1,7 @@ +function print_hello() { + console.log('hello world from maxdepth/not-affected'); +} + +window.addEventListener('load', function () { + print_hello(); +});