blob: 56e4acc3aafc5ccf42112722fbc3bf450ed271c0 [file] [log] [blame]
janakrf00d6242018-03-06 14:56:45 -08001// Copyright 2018 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.skyframe;
16
nharmata4ec695c2019-02-19 08:30:22 -080017import com.google.common.collect.ImmutableList;
shahan602cc852018-06-06 20:09:57 -070018import com.google.devtools.build.lib.actions.FileStateValue;
19import com.google.devtools.build.lib.actions.FileValue;
janakrf00d6242018-03-06 14:56:45 -080020import com.google.devtools.build.lib.skyframe.serialization.testutils.FsUtils;
21import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester;
janakrf00d6242018-03-06 14:56:45 -080022import com.google.devtools.build.lib.vfs.PathFragment;
23import org.junit.Test;
24import org.junit.runner.RunWith;
25import org.junit.runners.JUnit4;
26
27/** Tests for {@link FileValue}. */
28@RunWith(JUnit4.class)
29public class FileValueTest {
30 @Test
31 public void testCodec() throws Exception {
nharmataf93c72c2020-03-13 14:22:10 -070032 SerializationTester serializationTester =
33 new SerializationTester(
janakrf00d6242018-03-06 14:56:45 -080034 // Assume we have adequate coverage for FileStateValue serialization.
35 new FileValue.RegularFileValue(
nharmataf93c72c2020-03-13 14:22:10 -070036 FsUtils.TEST_ROOTED_PATH, FileStateValue.NONEXISTENT_FILE_STATE_NODE),
nharmata4ec695c2019-02-19 08:30:22 -080037 new FileValue.DifferentRealPathFileValueWithStoredChain(
nharmataf93c72c2020-03-13 14:22:10 -070038 FsUtils.TEST_ROOTED_PATH,
nharmata4ec695c2019-02-19 08:30:22 -080039 FileStateValue.DIRECTORY_FILE_STATE_NODE,
nharmataf93c72c2020-03-13 14:22:10 -070040 ImmutableList.of(FsUtils.TEST_ROOTED_PATH)),
nharmata4ec695c2019-02-19 08:30:22 -080041 new FileValue.DifferentRealPathFileValueWithoutStoredChain(
nharmataf93c72c2020-03-13 14:22:10 -070042 FsUtils.TEST_ROOTED_PATH, FileStateValue.DIRECTORY_FILE_STATE_NODE),
nharmata4ec695c2019-02-19 08:30:22 -080043 new FileValue.SymlinkFileValueWithStoredChain(
nharmataf93c72c2020-03-13 14:22:10 -070044 FsUtils.TEST_ROOTED_PATH,
nharmata4ec695c2019-02-19 08:30:22 -080045 new FileStateValue.RegularFileStateValue(
46 /*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null),
nharmataf93c72c2020-03-13 14:22:10 -070047 ImmutableList.of(FsUtils.TEST_ROOTED_PATH),
nharmata4ec695c2019-02-19 08:30:22 -080048 PathFragment.create("somewhere/else")),
49 new FileValue.SymlinkFileValueWithoutStoredChain(
nharmataf93c72c2020-03-13 14:22:10 -070050 FsUtils.TEST_ROOTED_PATH,
janakrf00d6242018-03-06 14:56:45 -080051 new FileStateValue.RegularFileStateValue(
52 /*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null),
nharmataf93c72c2020-03-13 14:22:10 -070053 PathFragment.create("somewhere/else")));
54 FsUtils.addDependencies(serializationTester);
55 serializationTester.runTests();
janakrf00d6242018-03-06 14:56:45 -080056 }
57}